forked from enlightenment/efl
elm cnp win32 - do one side at least of unix newlines to windows newln
this PARTLY addresses 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
This commit is contained in:
parent
1b8643b9a0
commit
b3d40d393e
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue