forked from enlightenment/terminology
parent
e0e7fbfd94
commit
abc8235dff
|
@ -1189,7 +1189,7 @@ termio_selection_get(Evas_Object *obj, int c1x, int c1y, int c2x, int c2y)
|
|||
{
|
||||
Termio *sd = evas_object_smart_data_get(obj);
|
||||
Eina_Strbuf *sb;
|
||||
char *s, txt[8];
|
||||
char *s;
|
||||
int x, y;
|
||||
|
||||
if (!sd) return NULL;
|
||||
|
@ -1225,39 +1225,43 @@ termio_selection_get(Evas_Object *obj, int c1x, int c1y, int c2x, int c2y)
|
|||
else if (cells[x].att.newline)
|
||||
{
|
||||
last0 = -1;
|
||||
eina_strbuf_append(sb, "\n");
|
||||
eina_strbuf_append_char(sb, '\n');
|
||||
break;
|
||||
}
|
||||
else if (cells[x].att.tab)
|
||||
{
|
||||
eina_strbuf_append(sb, "\t");
|
||||
eina_strbuf_append_char(sb, '\t');
|
||||
x = ((x + 8) / 8) * 8;
|
||||
x--;
|
||||
}
|
||||
else
|
||||
{
|
||||
char txt[8];
|
||||
int txtlen;
|
||||
|
||||
if (last0 >= 0)
|
||||
{
|
||||
v = x - last0 - 1;
|
||||
last0 = -1;
|
||||
while (v >= 0)
|
||||
{
|
||||
eina_strbuf_append(sb, " ");
|
||||
eina_strbuf_append_char(sb, ' ');
|
||||
v--;
|
||||
}
|
||||
if (x == (w - 1))
|
||||
{
|
||||
if (!cells[x].att.autowrapped)
|
||||
eina_strbuf_append(sb, "\n");
|
||||
eina_strbuf_append_char(sb, '\n');
|
||||
}
|
||||
}
|
||||
glyph_to_utf8(cells[x].glyph, txt);
|
||||
eina_strbuf_append(sb, txt);
|
||||
txtlen = glyph_to_utf8(cells[x].glyph, txt);
|
||||
if (txtlen > 0)
|
||||
eina_strbuf_append_length(sb, txt, txtlen);
|
||||
}
|
||||
}
|
||||
if (last0 >= 0)
|
||||
{
|
||||
eina_strbuf_append(sb, "\n");
|
||||
eina_strbuf_append_char(sb, '\n');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
#include "utf8.h"
|
||||
|
||||
void
|
||||
int
|
||||
glyph_to_utf8(int g, char *txt)
|
||||
{
|
||||
if (g < (1 << (7)))
|
||||
{ // 0xxxxxxx
|
||||
txt[0] = g & 0x7f;
|
||||
txt[1] = 0;
|
||||
return 1;
|
||||
}
|
||||
else if (g < (1 << (5 + 6)))
|
||||
{ // 110xxxxx 10xxxxxx
|
||||
txt[0] = 0xc0 | ((g >> 6) & 0x1f);
|
||||
txt[1] = 0x80 | ((g ) & 0x3f);
|
||||
txt[2] = 0;
|
||||
return 2;
|
||||
}
|
||||
else if (g < (1 << (4 + 6 + 6)))
|
||||
{ // 1110xxxx 10xxxxxx 10xxxxxx
|
||||
|
@ -20,6 +22,7 @@ glyph_to_utf8(int g, char *txt)
|
|||
txt[1] = 0x80 | ((g >> 6 ) & 0x3f);
|
||||
txt[2] = 0x80 | ((g ) & 0x3f);
|
||||
txt[3] = 0;
|
||||
return 3;
|
||||
}
|
||||
else if (g < (1 << (3 + 6 + 6 + 6)))
|
||||
{ // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
|
@ -28,6 +31,7 @@ glyph_to_utf8(int g, char *txt)
|
|||
txt[2] = 0x80 | ((g >> 6 ) & 0x3f);
|
||||
txt[3] = 0x80 | ((g ) & 0x3f);
|
||||
txt[4] = 0;
|
||||
return 4;
|
||||
}
|
||||
else if (g < (1 << (2 + 6 + 6 + 6 + 6)))
|
||||
{ // 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
|
@ -37,6 +41,7 @@ glyph_to_utf8(int g, char *txt)
|
|||
txt[3] = 0x80 | ((g >> 6 ) & 0x3f);
|
||||
txt[4] = 0x80 | ((g ) & 0x3f);
|
||||
txt[5] = 0;
|
||||
return 5;
|
||||
}
|
||||
else if (g < (1 << (1 + 6 + 6 + 6 + 6 + 6)))
|
||||
{ // 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
|
@ -47,10 +52,11 @@ glyph_to_utf8(int g, char *txt)
|
|||
txt[4] = 0x80 | ((g >> 6 ) & 0x3f);
|
||||
txt[5] = 0x80 | ((g ) & 0x3f);
|
||||
txt[6] = 0;
|
||||
return 6;
|
||||
}
|
||||
else
|
||||
{ // error - cant encode this in utf8
|
||||
txt[0] = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
void glyph_to_utf8(int g, char *txt);
|
||||
int glyph_to_utf8(int g, char *txt);
|
||||
|
||||
|
|
Loading…
Reference in New Issue