Re: Wrong result of get_position()

new topic     » goto parent     » topic index » view thread      » older message » newer message
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 thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu