[E-devel] use of ecore_time_get()

2009-02-20 Thread Vincent Torri

Hey,

the doc of ecore_time_get() says that it returns the number of second (as 
a double) from a specific date (because of gettimeofday()).

On Windows, to simulate gettimeofday(), I have to do a lot of 
computations, with a precision of 1E-3.

I can use another option, to get a higher precision (1E-6 or 1E-9), with a 
lot less computations, but without returning the number of seconds since 
1st january 1970.

My question is: is ecore_time_get() used for something else that measuring 
the time between 2 moments ? If no, I think that I can use those high 
resolution timers on Windows.

thank you

Vincent

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] use of ecore_time_get()

2009-02-20 Thread Vincent Torri


On Fri, 20 Feb 2009, Gustavo Sverzut Barbieri wrote:

 My question is: is ecore_time_get() used for something else that measuring
 the time between 2 moments ? If no, I think that I can use those high
 resolution timers on Windows.

 Sometimes I use it to get real time, to print or insert in db, easy to
 change if required, but I wonder: is your time in seconds, or what?
 Isn't it easy to apply an offset and scale to get the number of
 seconds, at least approximately?

then it will be exatly the same computations than the current code, with 
just a higher precision. The problem is more the computations, which are a 
bit heavy to get the same value than gettimeofday().

Vincent

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] use of ecore_time_get()

2009-02-20 Thread Gustavo Sverzut Barbieri
On Fri, Feb 20, 2009 at 8:09 AM, Vincent Torri vto...@univ-evry.fr wrote:

 Hey,

 the doc of ecore_time_get() says that it returns the number of second (as
 a double) from a specific date (because of gettimeofday()).

 On Windows, to simulate gettimeofday(), I have to do a lot of
 computations, with a precision of 1E-3.

 I can use another option, to get a higher precision (1E-6 or 1E-9), with a
 lot less computations, but without returning the number of seconds since
 1st january 1970.

 My question is: is ecore_time_get() used for something else that measuring
 the time between 2 moments ? If no, I think that I can use those high
 resolution timers on Windows.

Sometimes I use it to get real time, to print or insert in db, easy to
change if required, but I wonder: is your time in seconds, or what?
Isn't it easy to apply an offset and scale to get the number of
seconds, at least approximately?

-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--
MSN: barbi...@gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] use of ecore_time_get()

2009-02-20 Thread Vincent Torri


On Fri, 20 Feb 2009, Gustavo Sverzut Barbieri wrote:

 On Fri, Feb 20, 2009 at 11:04 AM, Vincent Torri vto...@univ-evry.fr wrote:


 On Fri, 20 Feb 2009, Gustavo Sverzut Barbieri wrote:

 My question is: is ecore_time_get() used for something else that
 measuring
 the time between 2 moments ? If no, I think that I can use those high
 resolution timers on Windows.

 Sometimes I use it to get real time, to print or insert in db, easy to
 change if required, but I wonder: is your time in seconds, or what?
 Isn't it easy to apply an offset and scale to get the number of
 seconds, at least approximately?

 then it will be exatly the same computations than the current code, with
 just a higher precision. The problem is more the computations, which are a
 bit heavy to get the same value than gettimeofday().

 Well, is it that heavy? I mean, the real code is used just few times
 per loop, if one uses ecore_loop_time_get() it's just one, so should
 not impact at all. But I'd say we can use a compile-time switch and
 let some embedded users choose the fast or the precise way.

well, in evil, i compute the # of seconds since 1st january 1970, then i 
tranformat that to get something similar to gettimeofday, then 
ecore_time_get() re-tranform again what i got to obtain the number of 
seconds. That's why i say heavy.

I wanted to avoid to add windows code, but maybe i should actually add it 
in ecore, t avoid extra computations

Vincent

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] use of ecore_time_get()

2009-02-20 Thread Gustavo Sverzut Barbieri
On Fri, Feb 20, 2009 at 11:04 AM, Vincent Torri vto...@univ-evry.fr wrote:


 On Fri, 20 Feb 2009, Gustavo Sverzut Barbieri wrote:

 My question is: is ecore_time_get() used for something else that
 measuring
 the time between 2 moments ? If no, I think that I can use those high
 resolution timers on Windows.

 Sometimes I use it to get real time, to print or insert in db, easy to
 change if required, but I wonder: is your time in seconds, or what?
 Isn't it easy to apply an offset and scale to get the number of
 seconds, at least approximately?

 then it will be exatly the same computations than the current code, with
 just a higher precision. The problem is more the computations, which are a
 bit heavy to get the same value than gettimeofday().

Well, is it that heavy? I mean, the real code is used just few times
per loop, if one uses ecore_loop_time_get() it's just one, so should
not impact at all. But I'd say we can use a compile-time switch and
let some embedded users choose the fast or the precise way.

Regards,

-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--
MSN: barbi...@gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


[E-devel] [PATCH] Eterm utf8 hack.

2009-02-20 Thread Kim Woelders
I refuse to surrender to SFs attachment stripping just yet...
diff --git a/src/command.h b/src/command.h
index 4b40713..f7d91e3 100644
--- a/src/command.h
+++ b/src/command.h
@@ -269,7 +269,7 @@ if (test) PrivateModes |= (bit); else PrivateModes = ~(bit);} while (0)
 #define CHARS_READ()  (cmdbuf_ptr  cmdbuf_endp)
 #define CHARS_BUFFERED()  (count != CMD_BUF_SIZE)
 #define RETURN_CHAR() do { \
-char c = *cmdbuf_ptr++; \
+unsigned char c = *cmdbuf_ptr++; \
 refreshed = 0; \
 if (c  32) D_VT((RETURN_CHAR():  \'%s\' (%d 0x%02x %03o)\n, get_ctrl_char_name(c), c, c, c)); \
 else D_VT((RETURN_CHAR():  \'%c\' (%d 0x%02x %03o)\n, c, c, c, c)); \
diff --git a/src/screen.c b/src/screen.c
index 605f5cf..2835876 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -29,6 +29,7 @@ static const char cvs_ident[] = $Id: screen.c 34573 2008-05-14 22:26:36Z mej $
 #ifdef HAVE_X11_XMU_ATOMS_H
 # include X11/Xmu/Atoms.h
 #endif
+#include iconv.h
 
 #include buttons.h
 #include command.h
@@ -112,9 +113,10 @@ blank_line(text_t *et, rend_t *er, int width, rend_t efs)
 register unsigned int i = width;
 rend_t *r = er, fs = efs;
 
-MEMSET(et, ' ', i);
-for (; i--;)
+for (; i--;) {
+*et++ = ' ';
 *r++ = fs;
+}
 }
 
 /* Create a new row in the screen buffer and initialize it. */
@@ -124,15 +126,18 @@ blank_screen_mem(text_t **tp, rend_t **rp, int row, rend_t efs)
 {
 register unsigned int i = TERM_WINDOW_GET_REPORTED_COLS();
 rend_t *r, fs = efs;
+text_t *et;
 
 if (tp[row] == NULL) {
 tp[row] = MALLOC(sizeof(text_t) * (TERM_WINDOW_GET_REPORTED_COLS() + 1));
 rp[row] = MALLOC(sizeof(rend_t) * TERM_WINDOW_GET_REPORTED_COLS());
 }
-MEMSET(tp[row], ' ', i);
 tp[row][i] = 0;
-for (r = rp[row]; i--;)
+et = tp[row];
+for (r = rp[row]; i--;) {
+*et++ = ' ';
 *r++ = fs;
+}
 }
 
 void
@@ -690,6 +695,39 @@ scroll_text(int row1, int row2, int count, int spec)
 return count;
 }
 
+#undef FIXME_BLOCK
+#define FIXME_BLOCK 1
+
+#define UTF8_DEBUG 0
+
+static text_t *
+mb2text(const char *str, int *len)
+{
+static iconv_t ih = (iconv_t)-1;
+text_t *tstr;
+char *pi, *po;
+int   olen, maxolen;
+
+maxolen = *len * sizeof(text_t);
+tstr = MALLOC(maxolen);
+pi = (char*)str;
+po = (char*)tstr;
+if (ih == (iconv_t)-1)
+ih = iconv_open(UCS-2, UTF-8);
+olen = maxolen;
+iconv(ih, pi, len, po, olen);
+olen = (maxolen - olen) / 2;
+#if UTF8_DEBUG
+int i;
+printf(TO UCS2:);
+for (i = 0; i  olen; i++)
+   printf( %04x, tstr[i]);
+printf( UCS2 len=%d\n, olen);
+#endif
+*len = olen;
+return tstr;
+}
+
 /*
  * Add text given in str of length len to screen struct
  */
@@ -697,12 +735,12 @@ void
 scr_add_lines(const unsigned char *str, int nlines, int len)
 {
 /*charc; */
-register char c;
+register text_t c;
 
 /*int i, j, row, last_col; */
 int last_col;
 register int i, j, row;
-text_t *stp;
+text_t *stp, *tstr;
 rend_t *srp;
 row_col_t beg, end;
 
@@ -745,8 +783,11 @@ scr_add_lines(const unsigned char *str, int nlines, int len)
 chstat = WBYTE;
 #endif
 
+/* Convert incoming (mb) string to UCS-2 */
+tstr = mb2text(str, len);
+
 for (i = 0; i  len;) {
-c = str[i++];
+c = tstr[i++];
 #ifdef MULTI_CHARSET
 if ((encoding_method != LATIN1)  (chstat == WBYTE)) {
 rstyle |= RS_multiMask; /* multibyte 2nd byte */
@@ -829,6 +870,9 @@ scr_add_lines(const unsigned char *str, int nlines, int len)
 screen.flags = ~Screen_WrapNext;
 }
 }
+
+FREE(tstr);
+
 LOWER_BOUND(stp[last_col], screen.col);
 if (screen.col == 0) {
 end.col = last_col - 1;
@@ -1629,6 +1673,50 @@ scr_multi2(void)
 }
 #endif /* MULTI_CHARSET */
 
+static int
+scr_draw_string(Display *dpy, Drawable draw, GC gc, int x, int y, text_t *str, int len)
+{
+unsigned short buf[2048];
+int i;
+
+if (len  2048)
+len = 2048;
+#if UTF8_DEBUG
+for (i = 0; i  len; i++)
+{
+   buf[i] = (str[i]  8) | (str[i]  8);
+   printf( %04x, buf[i]);
+}
+printf(\n);
+#else
+for (i = 0; i  len; i++)
+   buf[i] = (str[i]  8) | (str[i]  8);
+#endif
+XDrawString16(dpy, draw, gc, x, y, (XChar2b*)buf, len);
+}
+
+static int
+scr_draw_image_string(Display *dpy, Drawable draw, GC gc, int x, int y, text_t *str, int len)
+{
+unsigned short buf[2048];
+int i;
+
+if (len  2048)
+len = 2048;
+#if UTF8_DEBUG
+for (i = 0; i  len; i++)
+{
+   buf[i] = (str[i]  8) | (str[i]  8);
+   printf( %04x, buf[i]);
+}
+printf(\n);
+#else
+for (i = 0; i  len; i++)
+   buf[i] = (str[i]  8) | (str[i]  8);
+#endif
+XDrawImageString16(dpy, draw, gc, 

Re: [E-devel] Eterm and utf8

2009-02-20 Thread Kim Woelders
Sorry about that.

- It should be possible to send patch attachments to this list.
- I'm not the biggest fan of t...@$! around here.
- It seems I got the patch sneaked through now.

/Kim


On Fri, 20 Feb 2009 04:21:04 +0100, Toma tomha...@gmail.com wrote:

 Patch was not included in the email. Might be best to create a bug on
 trac.enlightenment.org/e/ and attach the patch. There may already be a
 bug open for UTF8 support...

 -Toma.


 2009/2/20 Kim Woelders k...@woelders.dk:
 Hello,

 It is annoying that Eterm doesn't handle utf8. Here is a half-baked  
 patch
 that might inspire somebody (Michael? :) ) to do it properly.

 Beware! This patch breaks things in non-utf8 locales, probably doesn't  
 work
 on big-endian platforms, and is not suited for anything except playing
 around.

 That said, things seem to work fairly well with e.g. LANG=en_US.UTF-8  
 and
 selecting a good font, e.g.
 Eterm -F  
 -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1

 With -misc-fixed-medium-r-normal-ja-13-120-75-75-c-120-iso10646-1 it  
 even
 looks like Japanese and Korean is rendered correctly but there is some
 weirdness with column stepping (every second column is skipped).

 /Kim
 --
 Open Source Business Conference (OSBC), March 24-25, 2009, San  
 Francisco, CA
 -OSBC tackles the biggest issue in open source: Open Sourcing the  
 Enterprise
 -Strategies to boost innovation and cut costs with open source  
 participation
 -Receive a $600 discount off the registration fee with the source code:  
 SFAD
 http://p.sf.net/sfu/XcvMzF8H
 ___
 enlightenment-devel mailing list
 enlightenment-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/enlightenment-devel



 --
 Open Source Business Conference (OSBC), March 24-25, 2009, San  
 Francisco, CA
 -OSBC tackles the biggest issue in open source: Open Sourcing the  
 Enterprise
 -Strategies to boost innovation and cut costs with open source  
 participation
 -Receive a $600 discount off the registration fee with the source code:  
 SFAD
 http://p.sf.net/sfu/XcvMzF8H
 ___
 enlightenment-devel mailing list
 enlightenment-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] Eterm and utf8

2009-02-20 Thread Peter Wehrfritz
Kim Woelders schrieb:
 Hello,

 It is annoying that Eterm doesn't handle utf8. Here is a half-baked 
 patch that might inspire somebody (Michael? :) ) to do it properly.

Or maybe one gsoc student :).

 Beware! This patch breaks things in non-utf8 locales, probably doesn't 
 work on big-endian platforms, and is not suited for anything except 
 playing around.

 That said, things seem to work fairly well with e.g. LANG=en_US.UTF-8 
 and selecting a good font, e.g.
 Eterm -F -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1

 With -misc-fixed-medium-r-normal-ja-13-120-75-75-c-120-iso10646-1 it 
 even looks like Japanese and Korean is rendered correctly but there is 
 some weirdness with column stepping (every second column is skipped).

I've seen in your patch that you are converting the text to ucs-2. which 
is, as you probably know, only a subset of unicode 4.0 and hence doesn't 
cover all UTF-8 supported characters. I guess that most (probably all) 
Unicode character beyond the scope of ucs-2 aren't used widely. I doubt 
that someone uses Ancient Greek Musical Notation-characters in a 
terminal application, but wouldn't it be better to support the whole 
UTF-8 character set, even if it is only for the sake of completeness?

Peter

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] Eterm and utf8

2009-02-20 Thread Kim Woelders
On Fri, 20 Feb 2009 20:09:30 +0100, Peter Wehrfritz peter.wehrfr...@web.de 
wrote:

 Kim Woelders schrieb:
 Hello,

 It is annoying that Eterm doesn't handle utf8. Here is a half-baked  
 patch that might inspire somebody (Michael? :) ) to do it properly.

 Or maybe one gsoc student :).

 Beware! This patch breaks things in non-utf8 locales, probably doesn't  
 work on big-endian platforms, and is not suited for anything except  
 playing around.

 That said, things seem to work fairly well with e.g. LANG=en_US.UTF-8  
 and selecting a good font, e.g.
 Eterm -F  
 -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1

 With -misc-fixed-medium-r-normal-ja-13-120-75-75-c-120-iso10646-1 it  
 even looks like Japanese and Korean is rendered correctly but there is  
 some weirdness with column stepping (every second column is skipped).

 I've seen in your patch that you are converting the text to ucs-2. which  
 is, as you probably know, only a subset of unicode 4.0 and hence doesn't  
 cover all UTF-8 supported characters. I guess that most (probably all)  
 Unicode character beyond the scope of ucs-2 aren't used widely. I doubt  
 that someone uses Ancient Greek Musical Notation-characters in a  
 terminal application, but wouldn't it be better to support the whole  
 UTF-8 character set, even if it is only for the sake of completeness?

Yes. UCS-2 is used as internal encoding in this patch. It is what I found all 
in all seemed to give best results.
It might be considered to use UCS-2BE internally to avoid some byte swapping, 
but I got in trouble with that somewhere.

I have a similar patch where the internal encoding is wchar_t and 
mbstowcs/XwcDraw[Image]String/XFontSet are used.
I found it very hard if not impossible to select a proper font set. Either I'm 
stupid or that just doesn't work properly.

I'm fairly convinced that using UCS2 is fine for all practical purposes and I 
think that implementing utf8 support at all is more important than going for 
completeness and support for ancient whatnot :)

It could also be considered to use Xft, but again, I'm having trouble selecting 
the font I want in stead of some silly antialised one. However, there are 
reasons to try and get this right (the old X11 font system kind of being on the 
road to deprecation).

/Kim

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] Eterm and utf8

2009-02-20 Thread Peter Wehrfritz
Kim Woelders schrieb:

 Yes. UCS-2 is used as internal encoding in this patch. It is what I 
 found all in all seemed to give best results.
 It might be considered to use UCS-2BE internally to avoid some byte 
 swapping, but I got in trouble with that somewhere.

 I have a similar patch where the internal encoding is wchar_t and 
 mbstowcs/XwcDraw[Image]String/XFontSet are used.
 I found it very hard if not impossible to select a proper font set. 
 Either I'm stupid or that just doesn't work properly.

I hoped that maybe Xmb* or Xutf8* (maybe not very portable) functions 
could work.

 I'm fairly convinced that using UCS2 is fine for all practical 
 purposes and I think that implementing utf8 support at all is more 
 important than going for completeness and support for ancient whatnot :)

That's true :).

 It could also be considered to use Xft, but again, I'm having trouble 
 selecting the font I want in stead of some silly antialised one. 
 However, there are reasons to try and get this right (the old X11 font 
 system kind of being on the road to deprecation).

 /Kim


Sorry my ignorance, I haven't imagined that it could be such 
complicated. And of course if you have to choose between impossible 
and works for everyone, you should take the latter. :)

Peter

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel