[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: tgoto(3) says col,row but it seems to be x,col?
From: |
Thomas Dickey |
Subject: |
Re: tgoto(3) says col,row but it seems to be x,col? |
Date: |
Sat, 19 Mar 2016 13:21:27 -0400 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Sat, Mar 19, 2016 at 04:40:17PM +0100, Steffen Nurpmeso wrote:
> Hello,
>
> and termcap(5) says "ch Move cursor horizontally only to column
> %1" and terminfo(5) says "column_address hpa ch horizontal
> %position #1, absolute (P)", but when i'm doing
> n_termcap_cmd(n_TERMCAP_CMD_ch, w, -1) which translates to
> tgoto(cp, a1, a2) then nothing happens, i have to write
> tgoto(cp,0,a1) instead.
yes, that's right, but puzzling
The problem is that tgoto documention refers to "col,row" but
two-parameter cursor movement strings conventionally put the row
first. So tgoto has "always" reversed those parameters.
Also, tgoto does not pay any attention to the number of parameters
a capability uses: it simply reverses all of the col/row to row/col
values.
(I made a to-do item to clarify the manpage...)
> I.e., the following program moves the cursor to column 42!
> That's not right, is it. This is on current ArchLinux.
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
>
> #include <curses.h>
> #include <term.h>
>
> int main(void){
> char buf[4096], *bp, *c_ch, *cp;
>
> if(tgetent(bp = buf, getenv("TERM")) <= 0)
> return 1;
>
> if((c_ch = tgetstr("ch", NULL)) == NULL)
> return 2;
>
> if((cp = tgoto(c_ch, 5, 42)) == NULL)
> return 3;
>
> printf("\n");
> tputs(cp, 1, putchar);
> fflush(stdout);
> sleep(5);
> return 0;
> }
>
> --steffen
>
> _______________________________________________
> Bug-ncurses mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/bug-ncurses
--
Thomas E. Dickey <address@hidden>
http://invisible-island.net
ftp://invisible-island.net
signature.asc
Description: Digital signature