Exemplo n.º 1
0
Arquivo: ui.c Projeto: SLieng/nvm
void ui_puts(uint8_t *str)
{
  uint8_t *p = str;
  uint8_t c;

  while ((c = *p)) {
    if (c < 0x20) {
      abort();
    }

    size_t clen = (size_t)mb_ptr2len(p);
    ui_call_put((String){ .data = (char *)p, .size = clen });
    col++;
    if (mb_ptr2cells(p) > 1) {
      // double cell character, blank the next cell
      ui_call_put((String)STRING_INIT);
      col++;
    }
    if (utf_ambiguous_width(utf_ptr2char(p))) {
      pending_cursor_update = true;
    }
    if (col >= width) {
      ui_linefeed();
    }
    p += clen;

    if (p_wd) {  // 'writedelay': flush & delay each time.
      ui_flush();
      uint64_t wd = (uint64_t)labs(p_wd);
      os_delay(wd, false);
    }
  }
Exemplo n.º 2
0
void ui_line(ScreenGrid *grid, int row, int startcol, int endcol, int clearcol,
             int clearattr, bool wrap)
{
  LineFlags flags = wrap ? kLineFlagWrap : 0;
  if (startcol == -1) {
    startcol = 0;
    flags |= kLineFlagInvalid;
  }

  size_t off = grid->line_offset[row] + (size_t)startcol;

  ui_call_raw_line(grid->handle, row, startcol, endcol, clearcol, clearattr,
                   flags, (const schar_T *)grid->chars + off,
                   (const sattr_T *)grid->attrs + off);

  if (p_wd) {  // 'writedelay': flush & delay each time.
    int old_row = cursor_row, old_col = cursor_col;
    handle_T old_grid = cursor_grid_handle;
    // If 'writedelay' is active, set the cursor to indicate what was drawn.
    ui_grid_cursor_goto(grid->handle, row, MIN(clearcol, (int)Columns-1));
    ui_flush();
    uint64_t wd = (uint64_t)labs(p_wd);
    os_microdelay(wd * 1000u, true);
    ui_grid_cursor_goto(old_grid, old_row, old_col);
  }
}
Exemplo n.º 3
0
/*
 * print the changelist
 */
void ex_changes(exarg_T *eap)
{
  int i;
  char_u      *name;

  /* Highlight title */
  MSG_PUTS_TITLE(_("\nchange line  col text"));

  for (i = 0; i < curbuf->b_changelistlen && !got_int; ++i) {
    if (curbuf->b_changelist[i].mark.lnum != 0) {
      msg_putchar('\n');
      if (got_int)
        break;
      sprintf((char *)IObuff, "%c %3d %5ld %4d ",
          i == curwin->w_changelistidx ? '>' : ' ',
          i > curwin->w_changelistidx ? i - curwin->w_changelistidx
          : curwin->w_changelistidx - i,
          (long)curbuf->b_changelist[i].mark.lnum,
          curbuf->b_changelist[i].mark.col);
      msg_outtrans(IObuff);
      name = mark_line(&curbuf->b_changelist[i].mark, 17);
      msg_outtrans_attr(name, hl_attr(HLF_D));
      xfree(name);
      os_breakcheck();
    }
    ui_flush();
  }
  if (curwin->w_changelistidx == curbuf->b_changelistlen)
    MSG_PUTS("\n>");
}
Exemplo n.º 4
0
Arquivo: mark.c Projeto: ZyX-I/neovim
static void
show_one_mark(
    int c,
    char_u *arg,
    pos_T *p,
    char_u *name,
    int current                    /* in current file */
)
{
  static int did_title = FALSE;
  int mustfree = FALSE;

  if (c == -1) {                            /* finish up */
    if (did_title)
      did_title = FALSE;
    else {
      if (arg == NULL)
        MSG(_("No marks set"));
      else
        EMSG2(_("E283: No marks matching \"%s\""), arg);
    }
  }
  /* don't output anything if 'q' typed at --more-- prompt */
  else if (!got_int
           && (arg == NULL || vim_strchr(arg, c) != NULL)
           && p->lnum != 0) {
    if (!did_title) {
      /* Highlight title */
      MSG_PUTS_TITLE(_("\nmark line  col file/text"));
      did_title = TRUE;
    }
    msg_putchar('\n');
    if (!got_int) {
      sprintf((char *)IObuff, " %c %6ld %4d ", c, p->lnum, p->col);
      msg_outtrans(IObuff);
      if (name == NULL && current) {
        name = mark_line(p, 15);
        mustfree = TRUE;
      }
      if (name != NULL) {
        msg_outtrans_attr(name, current ? HL_ATTR(HLF_D) : 0);
        if (mustfree) {
          xfree(name);
        }
      }
    }
    ui_flush();                    /* show one line at a time */
  }
}
Exemplo n.º 5
0
Arquivo: ui.c Projeto: qvacua/neovim
void ui_line(int row, int startcol, int endcol, int clearcol, int clearattr,
             bool wrap)
{
  size_t off = LineOffset[row]+(size_t)startcol;
  UI_CALL(raw_line, 1, row, startcol, endcol, clearcol, clearattr, wrap,
          (const schar_T *)ScreenLines+off, (const sattr_T *)ScreenAttrs+off);
  if (p_wd) {  // 'writedelay': flush & delay each time.
    int old_row = row, old_col = col;
    // If'writedelay is active, we set the cursor to highlight what was drawn
    ui_cursor_goto(row, MIN(clearcol, (int)Columns-1));
    ui_flush();
    uint64_t wd = (uint64_t)labs(p_wd);
    os_microdelay(wd * 1000u, true);
    ui_cursor_goto(old_row, old_col);
  }
}
Exemplo n.º 6
0
void mch_exit(int r)
{
  exiting = TRUE;

  ui_builtin_stop();
  ui_flush();
  ml_close_all(TRUE);           /* remove all memfiles */

  event_teardown();

#ifdef EXITFREE
  free_all_mem();
#endif

  exit(r);
}
Exemplo n.º 7
0
void mch_exit(int r)
{
  exiting = true;

  ui_builtin_stop();
  ui_flush();
  ml_close_all(true);           /* remove all memfiles */

  event_teardown();
  stream_set_blocking(input_global_fd(), true);  // normalize stream (#2598)

#ifdef EXITFREE
  free_all_mem();
#endif

  exit(r);
}
Exemplo n.º 8
0
/*
 * print the jumplist
 */
void ex_jumps(exarg_T *eap)
{
  int i;
  char_u      *name;

  cleanup_jumplist();
  /* Highlight title */
  MSG_PUTS_TITLE(_("\n jump line  col file/text"));
  for (i = 0; i < curwin->w_jumplistlen && !got_int; ++i) {
    if (curwin->w_jumplist[i].fmark.mark.lnum != 0) {
      if (curwin->w_jumplist[i].fmark.fnum == 0)
        fname2fnum(&curwin->w_jumplist[i]);
      name = fm_getname(&curwin->w_jumplist[i].fmark, 16);
      if (name == NULL)             /* file name not available */
        continue;

      msg_putchar('\n');
      if (got_int) {
        xfree(name);
        break;
      }
      sprintf((char *)IObuff, "%c %2d %5ld %4d ",
          i == curwin->w_jumplistidx ? '>' : ' ',
          i > curwin->w_jumplistidx ? i - curwin->w_jumplistidx
          : curwin->w_jumplistidx - i,
          curwin->w_jumplist[i].fmark.mark.lnum,
          curwin->w_jumplist[i].fmark.mark.col);
      msg_outtrans(IObuff);
      msg_outtrans_attr(name,
          curwin->w_jumplist[i].fmark.fnum == curbuf->b_fnum
          ? hl_attr(HLF_D) : 0);
      xfree(name);
      os_breakcheck();
    }
    ui_flush();
  }
  if (curwin->w_jumplistidx == curwin->w_jumplistlen)
    MSG_PUTS("\n>");
}