diff options
Diffstat (limited to 'libterm/term.c')
-rw-r--r-- | libterm/term.c | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/libterm/term.c b/libterm/term.c index f1dbf40..e279e81 100644 --- a/libterm/term.c +++ b/libterm/term.c @@ -69,14 +69,14 @@ int term_get_maxcol( term_screen *ts ) int cur_c; /* get initial cursor position */ - if ( (orig_c = term_cur_pos_c( ts )) == -1 ) + if ( (orig_c = term_cur_get_c( ts )) == -1 ) goto exit_error; /* go to right marging and get position */ if ( write( ts->ofd, T_ESC "[999C", 6 ) != 6 ) goto exit_error; - if ( (cur_c = term_cur_pos_c( ts )) == -1 ) + if ( (cur_c = term_cur_get_c( ts )) == -1 ) goto exit_error; ret = cur_c; @@ -103,14 +103,14 @@ int term_get_maxrow( term_screen *ts ) int cur_r; /* get initial cursor position */ - if ( (orig_r = term_cur_pos_r( ts )) == -1 ) + if ( (orig_r = term_cur_get_r( ts )) == -1 ) goto exit_error; /* go to right marging and get position */ if ( write( ts->ofd, T_ESC "[999B", 6 ) != 6 ) goto exit_error; - if ( (cur_r = term_cur_pos_r( ts )) == -1 ) + if ( (cur_r = term_cur_get_r( ts )) == -1 ) goto exit_error; ret = cur_r; @@ -129,13 +129,7 @@ exit_error: -int term_cur_pos( term_screen *ts ) -{ - int ret=-1; - return ret; -} - -int term_cur_pos_c( term_screen *ts ) +int term_cur_get_c( term_screen *ts ) { unsigned int i; int row, col; @@ -162,7 +156,7 @@ exit_error: } -int term_cur_pos_r( term_screen *ts ) +int term_cur_get_r( term_screen *ts ) { unsigned int i; int row, col; @@ -195,7 +189,7 @@ int term_cur_set_c( term_screen *ts, unsigned int pc ) int cur_r; /* go to right marging and get position */ - if ( (cur_r = term_cur_pos_r( ts )) == -1 ) + if ( (cur_r = term_cur_get_r( ts )) == -1 ) goto exit_error; /* set position */ { @@ -221,7 +215,7 @@ int term_cur_set_r( term_screen *ts, unsigned int pr ) int cur_c; /* go to right marging and get position */ - if ( (cur_c = term_cur_pos_c( ts )) == -1 ) + if ( (cur_c = term_cur_get_c( ts )) == -1 ) goto exit_error; /* set position */ { @@ -240,6 +234,27 @@ exit_error: return -1; } +int term_cur_set_cr( term_screen *ts, unsigned int pc, unsigned int pr ) +{ + int ret = 0; + + /* set position */ + { + char buf[32]; + int l; + + snprintf( buf, 32, T_ESC "[%d;%dH", pr, pc); + l = strlen( buf ); + if ( write( ts->ofd, buf, l ) != l) + goto exit_error; + } + return ret; + +exit_error: + return -1; + +} + int term_set_speed( term_screen *ts ) { int ret = -1; @@ -252,7 +267,7 @@ int term_clr_scr( term_screen *ts ) { int ret = 0; - if ( write( ts->ofd, T_ESC "[H" T_ESC "[2J", 7 ) <= 0 );; + if ( write( ts->ofd, T_ESC "[H" T_ESC "[2J", 7 ) <= 0 ){}; return ret; } |