Пример #1
0
void xgc_grid_delete(window_textgrid_t *cutwin, int op)
{
  if (!DOT_EXISTS(&cutwin->dot))
    return;
  
  if (!dot_contains_dot(cutwin, &cutwin->inputdot, &cutwin->dot))
    return;
  
  if (cutwin->dot.endline > cutwin->inputdot.begline 
    || cutwin->dot.endchar > cutwin->inputdot.begchar + cutwin->inputmaxlen) {
    cutwin->dot.endline = cutwin->inputdot.begline;
    cutwin->dot.endchar = cutwin->inputdot.begchar + cutwin->inputmaxlen;
  }
  
  if (!DOT_LENGTH_ZERO(&cutwin->dot) 
    && (op == op_BackChar || op == op_ForeChar)) {
    kill_input(cutwin, cutwin->dot.begchar, cutwin->dot.endchar);
    win_textgrid_layout(cutwin, FALSE);
    return;
  }
  
  collapse_dot(cutwin);

  switch (op) {
  case op_BackChar:
    if (cutwin->dot.begchar > cutwin->inputdot.begchar)
      kill_input(cutwin, cutwin->dot.begchar-1, cutwin->dot.begchar);
    break;
  case op_ForeChar:
    kill_input(cutwin, cutwin->dot.begchar, cutwin->dot.begchar+1);
    break;
  }

  win_textgrid_layout(cutwin, FALSE);
}
Пример #2
0
void xgc_grid_insert(window_textgrid_t *cutwin, int ch)
{
  char realch;
  int ix, pos;
  
  /* ### not perfect -- should be all typable chars */
  if (ch < 32 || ch >= 127)
    ch = ' ';

  realch = ch;
  
  if (!DOT_EXISTS(&cutwin->dot)) {
    cutwin->dot.begline = 0;
    cutwin->dot.begchar = 0;
    collapse_dot_back(cutwin);
  }
  
  if (!DOT_LENGTH_ZERO(&cutwin->dot)) {
    kill_input(cutwin, cutwin->dot.begchar, cutwin->dot.endchar);
    collapse_dot_back(cutwin);
  }
  
  ix = compare_pos_to_dot(cutwin, &cutwin->inputdot, cutwin->dot.begchar, cutwin->dot.begline);
  if (ix == 0) {
    pos = cutwin->inputdot.begchar;
  }
  else if (ix == 3) {
    pos = cutwin->inputdot.begchar + cutwin->inputlen;
  }
  else {
    pos = cutwin->dot.begchar;
    if (pos > cutwin->inputdot.begchar + cutwin->inputlen)
      pos = cutwin->inputdot.begchar + cutwin->inputlen;
  }
  cutwin->cursory = cutwin->inputdot.begline;
  
  insert_input(cutwin, pos, &realch, 1);
  
  win_textgrid_layout(cutwin, FALSE);
}
Пример #3
0
static void stop_events(){
	printf("INFO: stop_events()\n");
   	kill_input();
}
Пример #4
0
void xgc_grid_cutbuf(window_textgrid_t *cutwin, int op)
{
  long len, num;
  char *buf, *cx;
  
  if (op != op_Copy) {
    if (!cutwin->buffer) {
      xmsg_set_message("You are not editing input in this window.", FALSE);
      return;
    }
  }
  
  switch (op) {
  case op_Copy:
    buf = xgrid_alloc_selection(cutwin, &cutwin->dot, &len);
    if (buf) {
      xglk_store_scrap(buf, len);
      free(buf);
    }
    break;
  case op_Wipe:
    buf = xgrid_alloc_selection(cutwin, &cutwin->dot, &len);
    if (buf) {
      xglk_store_scrap(buf, len);
      free(buf);
    }
    if (dot_contains_dot(cutwin, &cutwin->inputdot, &cutwin->dot)) {
      if (!DOT_LENGTH_ZERO(&cutwin->dot)) {
	kill_input(cutwin, cutwin->dot.begchar, cutwin->dot.endchar);
      }
    }
    break;
  case op_Erase:
    if (dot_contains_dot(cutwin, &cutwin->inputdot, &cutwin->dot)) {
      if (!DOT_LENGTH_ZERO(&cutwin->dot)) {
	kill_input(cutwin, cutwin->dot.begchar, cutwin->dot.endchar);
      }
    }
    break;
  case op_YankReplace:
    if (!dot_contains_dot(cutwin, &cutwin->inputdot, &cutwin->dot))
      break;
    xglk_fetch_scrap(&cx, &num);
    xglk_strip_garbage(cx, num);
    if (cx && num) {
      if (!DOT_LENGTH_ZERO(&cutwin->dot)) {
	kill_input(cutwin, cutwin->dot.begchar, cutwin->dot.endchar);
      }
      insert_input(cutwin, cutwin->dot.begchar, cx, num);
      free(cx);
    }
    break;
  case op_Untype:
    if (cutwin->inputlen > 0) {
      kill_input(cutwin, cutwin->inputdot.begchar, 
	cutwin->inputdot.begchar + cutwin->inputlen);
    }
    break;
  }

  win_textgrid_layout(cutwin, FALSE);
}