1. Wrong result of get_position()
- Posted by kinz Apr 26, 2011
- 1520 views
Dear EU-devs and users,
There is one problem in 4.0.2 same as in 3.1.1.
If I do get_position() after puts() of some mixed Russian/English text or pure Russian text in the Linux console using the utf-8 encoding, text is ok, but result of get_position() is wrong.
Try please my test program: http://private.peterlink.ru/kinz/3.2ru/get_posit.ex
using this lib: http://private.peterlink.ru/kinz/3.2ru/rus_add.e
Esc-command {27} & "[6n" works ok, but I do not know how to intercept its output into some variable in my EU program without printing on screen.
Regards
kinz
2. Re: Wrong result of get_position()
- Posted by SDPringle Apr 26, 2011
- 1515 views
Is \e6n] supposed to display the coordinates to the screen? If it does, you should expect that the act of displaying the value should change the value.
I can display these characters in jEdit but when I run this on my Windows console, the position values are correct but the characters are all wrong. Maybe you can tell us where on the screen the cursor goes on your screen.
10 20 30 40 50 60 70 0 90 100 110 120 1234567890123456789012345678901234567890123456789012345678901234567890123456789 1234567890123456789012345678901234567890 cp utf-8 -> ╨É╨░╨æ╨▒╨Æ╨▓╨ô╨│╨ö╨┤╨ò╨╡╨ü╤æ╨û╨╢╨ù ╨╖╨ÿ╨╕ asdfgh ---- ╨Ö╨╣╨Ü╨║╨¢ ╗╨£╨╝╨¥╨╜╨₧╨╛╨ƒ╨┐╨á╤Ç╨í╤ü╨ó╤é╨ú╤â╨ñ╤ä╨Ñ╤à╨ª╤å╨º╤ç╨¿╤ê╨⌐╤ë╨¬╤è╨½╤ï╨¼╤î╨¡╤ì╨«╤Ä╨» Å←[6n{7,6} {8,1}
Shawn
3. Re: Wrong result of get_position()
- Posted by mattlewis (admin) Apr 26, 2011
- 1489 views
Dear EU-devs and users,
There is one problem in 4.0.2 same as in 3.1.1.
If I do get_position() after puts() of some mixed Russian/English text or pure Russian text in the Linux console using the utf-8 encoding, text is ok, but result of get_position() is wrong.
The interpreter simply tracks the number of characters output and updates based on that. It's not UTF-8 aware, so it doesn't know that some of your characters are multi-byte. I'm not aware of a way to otherwise track the cursor position without using curses or something similar.
Esc-command {27} & "[6n" works ok, but I do not know how to intercept its output into some variable in my EU program without printing on screen.
I'm not aware of a way to do this.
Matt
4. Re: Wrong result of get_position()
- Posted by Vinoba Apr 26, 2011
- 1458 views
If you separately convert the UTF-8 to Unicode 16 bit LE and then you have exact two bytes per character. It would then be easy to find the nth character.
5. Re: Wrong result of get_position()
- Posted by kinz Apr 26, 2011
- 1436 views
Is \e6n] supposed to display the coordinates to the screen?
Yes it does.
If it does, you should expect that the act of displaying the value should change the value.
No, it doesn't see itself, it counts the positions of my letters only.
I can display these characters in jEdit but when I run this on my Windows console, the position values are correct but the characters are all wrong.
The Windows console doesn't work as utf-8 console. It is pure one-byte console. I do not have any problems there. I use cp866 and it is ok.
But Linux console is the utf-8 thing, so I have to recode cp866 to utf-8 to get Russian on the Linux screen. Or I can to do "unicode_stop" on that console, then load font and map, then use pure cp866. But after "unicode_stop" MC doesn't work properly.
Maybe you can tell us where on the screen the cursor goes on your screen.
Try please the Linux console and you'll see that picture yourself. And different Linux consoles give different results.
Regards
kinz
6. Re: Wrong result of get_position()
- Posted by kinz Apr 26, 2011
- 1414 views
If you separately convert the UTF-8 to Unicode 16 bit LE and then you have exact two bytes per character. It would then be easy to find the nth character.
Not that easy. I'd like to use the standard get_position()
Regards
kinz
7. Re: Wrong result of get_position()
- Posted by kinz Apr 26, 2011
- 1422 views
The interpreter simply tracks the number of characters output and updates based on that.
No, it doesn't. It uses some standard C-function from some lib of gcc, as far as I can see.
It's not UTF-8 aware, so it doesn't know that some of your characters are multi-byte. I'm not aware of a way to otherwise track the cursor position without using curses or something similar.
It doesn't use curses since 3.0
Regards
kinz
8. Re: Wrong result of get_position()
- Posted by mattlewis (admin) Apr 26, 2011
- 1454 views
The interpreter simply tracks the number of characters output and updates based on that.
No, it doesn't. It uses some standard C-function from some lib of gcc, as far as I can see.
get_position() ultimately calls GetTextPositionP() in be_w.c:
struct rccoord GetTextPositionP() { struct rccoord p; p.row = screen_line; p.col = screen_col; return p; }
screen_line and screen_col are updated when you output anything to the console.
It's not UTF-8 aware, so it doesn't know that some of your characters are multi-byte. I'm not aware of a way to otherwise track the cursor position without using curses or something similar.
It doesn't use curses since 3.0
Yes, I know. There is an ncurses library in the archive, however. I haven't looked at it in a long time, but if you're working on a console app that relies on text positioning, it's probably worth a look.
Matt
9. Re: Wrong result of get_position()
- Posted by ChrisB (moderator) Apr 26, 2011
- 1400 views
Hi
yes, that was me, I kind of started it, then lost interest - it does work with eu4 though, I tested it a few months ago, just haven't got back to it, because I have no need.
Chris