Exemplo n.º 1
0
/*---------------------------------------------------------------------------
|   Facility      :  libnmenu
|   Function      :  pos_menu_cursor
|
|   Description   :  Position logical cursor to current item in menu
|
|   Return Values :  E_OK            - success
|                    E_BAD_ARGUMENT  - invalid menu
|                    E_NOT_POSTED    - Menu is not posted
+--------------------------------------------------------------------------*/
int pos_menu_cursor(const MENU * menu)
{
  WINDOW *win, *sub;
  int x, y;
  int err = _nc_menu_cursor_pos(menu,(ITEM*)0,&y,&x);

  if (E_OK==err)
    {
      win = menu->userwin ? menu->userwin : stdscr;
      sub = menu->usersub ? menu->usersub : win;
      assert(win && sub);

      if ((menu->opt & O_SHOWMATCH) && (menu->pindex > 0))
	x += ( menu->pindex + menu->marklen - 1);

      wmove(sub,y,x);

      if ( win != sub )
	{
	  wcursyncup(sub);
	  wsyncup(sub);
	  untouchwin(sub);
	}
    }
  RETURN(err);
}
Exemplo n.º 2
0
pos_menu_cursor(const MENU * menu)
{
  WINDOW *win, *sub;
  int x = 0, y = 0;
  int err = _nc_menu_cursor_pos(menu, (ITEM *) 0, &y, &x);

  T((T_CALLED("pos_menu_cursor(%p)"), (const void *)menu));

  if (E_OK == err)
    {
      win = Get_Menu_UserWin(menu);
      sub = menu->usersub ? menu->usersub : win;
      assert(win && sub);

      if ((menu->opt & O_SHOWMATCH) && (menu->pindex > 0))
	x += (menu->pindex + menu->marklen - 1);

      wmove(sub, y, x);

      if (win != sub)
	{
	  wcursyncup(sub);
	  wsyncup(sub);
	  untouchwin(sub);
	}
    }
  RETURN(err);
}
Exemplo n.º 3
0
void hexedit_set_cursor(struct hexedit *buf)
{
	wmove(buf->win, max_rows(buf->win), 0);
	wattron(buf->win, A_REVERSE | A_STANDOUT);
	wclrtoeol(buf->win);
	if (buf->cursor_offset < buf->len) {
		wprintw(buf->win, "Len:%lu Off:%lu Val:0x%X", buf->len,
			buf->cursor_offset, buf->data[buf->cursor_offset]);
	} else {
		wprintw(buf->win, "Len:%lu Off:%lu", buf->len,
			buf->cursor_offset);
	}
	wattroff(buf->win, A_REVERSE | A_STANDOUT);
	wmove(buf->win, buf->cursor_y, buf->cursor_x);
	wcursyncup(buf->win);
	wsyncup(buf->win);
	untouchwin(buf->win);
}
Exemplo n.º 4
0
WINDOW *Xinitscr(int argc, char *argv[])
{
    int i;

    PDC_LOG(("Xinitscr() - called\n"));

    if (SP && SP->alive)
        return NULL;

    if (PDC_scr_open(argc, argv) == ERR)
    {
        fprintf(stderr, "initscr(): Unable to create SP\n");
        exit(8);
    }

    SP->autocr = TRUE;       /* cr -> lf by default */
    SP->raw_out = FALSE;     /* tty I/O modes */
    SP->raw_inp = FALSE;     /* tty I/O modes */
    SP->cbreak = TRUE;
    SP->save_key_modifiers = FALSE;
    SP->return_key_modifiers = FALSE;
    SP->echo = TRUE;
    SP->visibility = 1;
    SP->resized = FALSE;
    SP->_trap_mbe = 0L;
    SP->_map_mbe_to_key = 0L;
    SP->linesrippedoff = 0;
    SP->linesrippedoffontop = 0;
    SP->delaytenths = 0;
    SP->line_color = -1;

    SP->orig_cursor = PDC_get_cursor_mode();

    LINES = SP->lines;
    COLS = SP->cols;

    if (LINES < 2 || COLS < 2)
    {
        fprintf(stderr, "initscr(): LINES=%d COLS=%d: too small.\n",
                LINES, COLS);
        exit(4);
    }

    if ((curscr = newwin(LINES, COLS, 0, 0)) == (WINDOW *)NULL)
    {
        fprintf(stderr, "initscr(): Unable to create curscr.\n");
        exit(2);
    }

    if ((pdc_lastscr = newwin(LINES, COLS, 0, 0)) == (WINDOW *)NULL)
    {
        fprintf(stderr, "initscr(): Unable to create pdc_lastscr.\n");
        exit(2);
    }

    wattrset(pdc_lastscr, (chtype)(-1));
    werase(pdc_lastscr);

    PDC_slk_initialize();
    LINES -= SP->slklines;

    /* We have to sort out ripped off lines here, and reduce the height
       of stdscr by the number of lines ripped off */

    for (i = 0; i < linesrippedoff; i++)
    {
        if (linesripped[i].line < 0)
            (*linesripped[i].init)(newwin(1, COLS, LINES - 1, 0), COLS);
        else
            (*linesripped[i].init)(newwin(1, COLS,
                                   SP->linesrippedoffontop++, 0), COLS);

        SP->linesrippedoff++;
        LINES--;
    }

    linesrippedoff = 0;

    if (!(stdscr = newwin(LINES, COLS, SP->linesrippedoffontop, 0)))
    {
        fprintf(stderr, "initscr(): Unable to create stdscr.\n");
        exit(1);
    }

    wclrtobot(stdscr);

    /* If preserving the existing screen, don't allow a screen clear */

    if (SP->_preserve)
    {
        untouchwin(curscr);
        untouchwin(stdscr);
        stdscr->_clear = FALSE;
        curscr->_clear = FALSE;
    }
    else
        curscr->_clear = TRUE;

    PDC_init_atrtab();  /* set up default colors */

    MOUSE_X_POS = MOUSE_Y_POS = -1;
    BUTTON_STATUS(1) = BUTTON_RELEASED;
    BUTTON_STATUS(2) = BUTTON_RELEASED;
    BUTTON_STATUS(3) = BUTTON_RELEASED;
    Mouse_status.changes = 0;

    SP->alive = TRUE;

    def_shell_mode();

    sprintf(ttytype, "pdcurses|PDCurses for %s", PDC_sysname());

    return stdscr;
}