aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/elementary
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-07-26 16:44:10 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-07-26 16:44:10 +0900
commitb3d40d393e45d97619ef4b750b5295b2f3fdbd98 (patch)
treef947e841d196f8eb0d3c1e6e9835a544ffb777f0 /src/lib/elementary
parentefl ui image - fix view size get to NOT apply scaling (diff)
downloadefl-b3d40d393e45d97619ef4b750b5295b2f3fdbd98.tar.gz
elm cnp win32 - do one side at least of unix newlines to windows newln
this PARTLY addresses https://phab.enlightenment.org/T3556 ... this handles our own conversion of makrup to string then to a windows newlined string. this half. i wrote the conversion code for the other way but it's unused as i am unsure where exactly to plug in it. following the cnp code makes me not sure where it goes so for now - not there, but ready to go. to be clear. out API is unix text. utf8 strings at our api with UNIX newlines. that is our api. that is the text we accept and produce. if you deal with another file or interface that does not provide this then the job of conversion is AT THAT POINT. eg elm_cnp.c has to do this. as would file loads of text files (and saves) etc. - anything else like forgivingly handling anything at the api level makes it totally unclear what our api is and what should go in and come out. to be portable we have to define what it is and the most portable thing to do is at the api level within a process we define one and only one format. UNIX \n format. @fix - partial
Diffstat (limited to 'src/lib/elementary')
-rw-r--r--src/lib/elementary/elm_cnp.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/src/lib/elementary/elm_cnp.c b/src/lib/elementary/elm_cnp.c
index f9fdd14678..bab1076ab9 100644
--- a/src/lib/elementary/elm_cnp.c
+++ b/src/lib/elementary/elm_cnp.c
@@ -4526,6 +4526,56 @@ static Win32_Cnp_Selection _win32_selections[ELM_SEL_TYPE_CLIPBOARD + 1] =
}
};
+static char *
+_win32_text_n_to_rn(char *intext)
+{
+ size_t size = 0, newlines = 0;
+ char *outtext = NULL, *p, *o;
+
+ if (!intext) return NULL;
+ for (p = intext; *p; p++)
+ {
+ if (*p == '\n') newlines++;
+ size++;
+ }
+ outtext = malloc(size + newlines + 1);
+ if (!outtext) return intext;
+ for (p = intext, o = outtext; *p; p++, o++)
+ {
+ if (*p == '\n')
+ {
+ o++;
+ *p = '\r';
+ }
+ *o = *p;
+ }
+ *o = '\0';
+ free(intext);
+ return outtext;
+}
+
+static char *
+_win32_text_rn_to_n(char *intext)
+{
+ size_t size = 0, newlines = 0;
+ char *outtext = NULL, *p, *o;
+
+ if (!intext) return NULL;
+ outtext = malloc(strlen(intext) + 1);
+ if (!outtext) return intext;
+ for (p = intext, o = outtext; *p; p++, o++)
+ {
+ if ((*p == '\r') && (p[1] == '\n'))
+ {
+ p++;
+ *p = '\n';
+ }
+ else *o = *p;
+ }
+ *o = '\0';
+ free(intext);
+ return outtext;
+}
static void
_win32_sel_obj_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
@@ -4741,7 +4791,7 @@ _win32_elm_cnp_selection_get(Ecore_Win32_Window *win,
{
memcpy(str, data, size);
str[size] = '\0';
- data = _elm_util_mkup_to_text(str);
+ data = _win32_text_n_to_rn(_elm_util_mkup_to_text(str));
free(str);
if (data)
size = strlen(data);