1. Wrong result of get_position()

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

new topic     » topic index » view message » categorize

2. Re: Wrong result of get_position()

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

new topic     » goto parent     » topic index » view message » categorize

3. Re: Wrong result of get_position()

kinz said...

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.

kinz said...

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

new topic     » goto parent     » topic index » view message » categorize

4. Re: Wrong result of get_position()

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.

new topic     » goto parent     » topic index » view message » categorize

5. Re: Wrong result of get_position()

SDPringle said...

Is \e6n] supposed to display the coordinates to the screen?

Yes it does.

SDPringle said...

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.

SDPringle said...

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.

SDPringle said...

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

new topic     » goto parent     » topic index » view message » categorize

6. Re: Wrong result of get_position()

Vinoba said...

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

new topic     » goto parent     » topic index » view message » categorize

7. Re: Wrong result of get_position()

mattlewis said...

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.

mattlewis said...

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

new topic     » goto parent     » topic index » view message » categorize

8. Re: Wrong result of get_position()

kinz said...
mattlewis said...

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.

kinz said...
mattlewis said...

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

new topic     » goto parent     » topic index » view message » categorize

9. Re: Wrong result of get_position()

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

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu