/*---------------------------------------------------------------------- Move the cursor to the row and column number Input: row number column number Result: Cursor moves internal position updated ----------------------------------------------------------------------*/ void MoveCursor(int row, int col) { /** move cursor to the specified row column on the screen. 0,0 is the top left! **/ if(ps_global->in_init_seq) return; /* * This little hack is here for screen readers, for example, a screen * reader associated with a braille display. If we flash the cursor off * and on in the same position, the reader will be drawn to it. Since we * are calling MoveCursor every time through the message viewing loops we * need to suppress the calls if they aren't really doing anything. * However, mswin_move actually does more than just move the cursor. * It also call FlushAccum(), which is necessary in some cases. For * example, in optionally_enter the user is typing characters in and * the FlushAccum() allows them to show up on the screen. The putblock * call is a quick hack to get the Flush_Accum() call, which is all * the putblock does when the arg is NULL. */ if(row == _line && col == _col){ mswin_putblock(NULL, 0); return; } mswin_move(row, col); _line = row; _col = col; }
/* * invert_label - highlight the label of the given menu item. */ void invert_label(int state, MENUITEM *m) { int r, c; unsigned i, j; char *lp; int old_state; int wasShown; int col_offset; COLOR_PAIR *lastc = NULL; if(m->val == mnoop) return; mswin_getpos (&r, &c); /* get cursor position */ wasShown = mswin_showcaret (0); old_state = mswin_getrevstate (); /* * Leave the command name bold */ col_offset = (state || !(lp=strchr(m->label, ' '))) ? 0 : (lp - m->label); (*term.t_move)(m->tl.r, m->tl.c + col_offset); if(state && m->kncp) lastc = pico_set_colorp(m->kncp, PSC_REV|PSC_RET); else if(!state && m->klcp) lastc = pico_set_colorp(m->klcp, PSC_NORM|PSC_RET); else (*term.t_rev)(state); for(i = m->tl.r; i <= m->br.r; i++) { for(j = m->tl.c + col_offset; j <= m->br.c; j++) { if(i == m->lbl.r && j == m->lbl.c + col_offset){ /* show label?? */ lp = m->label + col_offset; while(*lp && j++ < m->br.c) (*term.t_putchar)(*lp++); continue; } else (*term.t_putchar)(' '); } } if(lastc){ (void)pico_set_colorp(lastc, PSC_NONE); free_color_pair(&lastc); } else (*term.t_rev)(old_state); mswin_move (r, c); mswin_showcaret (wasShown); }
/*---------------------------------------------------------------------- Clear the terminal screen ----------------------------------------------------------------------*/ void ClearScreen(void) { _line = 0; /* clear leaves us at top... */ _col = 0; if(ps_global->in_init_seq) return; mark_status_unknown(); mark_keymenu_dirty(); mark_titlebar_dirty(); mswin_move(0, 0); mswin_eeop(); }
/*---------------------------------------------------------------------- Write a character to the screen, keeping track of cursor position Input: charater to write Result: character output cursor position variables updated ----------------------------------------------------------------------*/ void Writewchar(UCS ucs) { int width; if(ps_global->in_init_seq) return; switch(ucs){ case LINE_FEED : _line = min(_line+1,ps_global->ttyo->screen_rows); _col =0; mswin_move(_line, _col); break; case RETURN : /* move to column 0 */ _col = 0; mswin_move(_line, _col); case BACKSPACE : /* move back a space if not in column 0 */ if(_col > 0) mswin_move(_line, --_col); break; case BELL : /* ring the bell but don't advance _col */ mswin_beep(); /* libpico call */ break; case TAB: /* if a tab, output it */ do mswin_putc(' '); while(((++_col)&0x07) != 0); break; default: /* pass_ctrl_chars is always 1 for Windows */ width = wcellwidth(ucs); if(width < 0){ mswin_putc('?'); _col++; } else if(_col + width > ps_global->ttyo->screen_cols){ int i; i = ps_global->ttyo->screen_cols - _col - 1; while(i-- > 0) mswin_putc(' '); _col = ps_global->ttyo->screen_cols - 1; mswin_move(_line, _col); mswin_putc('>'); _col++; } else{ mswin_putc(ucs); _col += width; } } if(_col >= ps_global->ttyo->screen_cols){ _col = ps_global->ttyo->screen_cols; mswin_move(_line, _col); } return; }