Example #1
0
void term_exit()                     /* close down the screen */
{
   textattr(norm_attrib);

   if (saved_lines != screen_h) {
      _set_screen_lines(saved_lines);
      cls();
   }
   else {
      goto2(0,screen_h-1);
      putch('\n');
   }

   _setcursortype(_NORMALCURSOR);
   show_c();
}
Example #2
0
void goto1(void){
  goto2();
}
Example #3
0
int do_input_text(char *buf, int size, int width, int (*valid)(char), int (*proc)(int, char *, int *, int *), int mouse_flag, int (*mouse_proc)(int x, int y, char *buf, int *oldlen))
{
   KEYPRESS k;
   int key;
   int askey;
   int ret;
   int x, y, len, cpos;
   int oldlen, c;
   int gap;
   int sel = TRUE;

   x = x_pos;
   y = y_pos;
   len = oldlen = cpos = strlen(buf);

   n_vid();

   do {
      goto1(x, y);

      if ((width > 0) && (len > width)) {
	 gap = len - width;

	 pch('.');
	 pch('.');
	 pch('.');
	 pch(' ');

	 mywrite(buf+gap+4);
      }
      else {
	 gap = 0;

	 mywrite(buf);
      }

      hi_vid();

      for (c=len-gap; c < ((width > 0) ? width : oldlen); c++)
	 pch(' ');

      oldlen = len;

      if (cpos-gap > 0)
	 goto2(x+cpos-gap, y);
      else
	 goto2(x, y);

      show_c();

      if (mouse_flag) {
	 display_mouse();
	 while (m_b)
	    poll_mouse();
	 while (TRUE) {
	    if (input_waiting()) {
	       k = input_char();
	       key = k.key;
	       if ((ascii(key) == CR) && (k.flags & KF_CTRL))
		  key = LF;
	       if (key)
		  break;
	    }
	    poll_mouse();
	    if ((m_b) && (mouse_proc)) {
	       hide_c(); 
	       key = (*mouse_proc)(x, y, buf, &oldlen);
	       len = cpos = strlen(buf);
	       sel = FALSE;
	       show_c();
	       if (key > 0)
		  break;
	    }
	 }
	 hide_mouse();
      }
      else {
	 while (m_b)
	    poll_mouse();

	 while ((!input_waiting()) && (!m_b))
	    poll_mouse();

	 if (m_b) {
	    if (m_b & 2)
	       key = ESC;
	    else
	       key = CR;
	 }
	 else {
	    k = input_char();
	    key = k.key;
	    if ((ascii(key) == CR) && (k.flags & KF_CTRL))
	       key = LF;
	 }
      }

      if ((!proc) || (!(*proc)(key, buf, &len, &cpos))) {

	 if ((key==CTRL_G) || (key==CTRL_C))
	    askey=ESC;
	 else
	    askey=ascii((char)key);

	 if ((askey==ESC) || (askey==CR) || (askey==LF)) {
	    ret = askey;
	    break;
	 }

	 if (key==LEFT_ARROW) {
	    if (cpos > 0)
	       cpos--;
	 }
	 else if (key==RIGHT_ARROW) {
	    if (cpos < len)
	       cpos++;
	 }
	 else if (key==K_HOME) {
	    cpos = 0;
	 }
	 else if (key==K_END) {
	    cpos = MAX(len, 0);
	 } 
	 else {
	    if ((sel) && ((key==K_DELETE) || (askey==BACKSPACE) || 
		  ((*valid)(askey)))) {
	       len = cpos = 0;
	       buf[0] = 0;
	    }

	    if (key==K_DELETE) {
	       if (cpos < len) {
		  for (c=cpos; c<len; c++)
		     buf[c] = buf[c+1];
		  len--;
	       }
	    }
	    else if (askey==BACKSPACE) {
	       if (cpos > 0) {
		  cpos--;
		  for (c=cpos; c<len; c++)
		     buf[c] = buf[c+1];
		  len--;
	       }
	    }
	    else {
	       if ((len<size) && ((*valid)(askey))) {
		  len++;
		  for (c=len; c>cpos; c--)
		     buf[c] = buf[c-1];
		  buf[cpos++]=askey;
	       }
	    }
	 }

	 if (proc)
	    (*proc)(-1, buf, &len, &cpos);
      }

      sel = FALSE;

   } while (TRUE);

   n_vid();
   return ret;
}
Example #4
0
File: gui.c Project: OrangeTide/fed
int fsel_mouse(int x, int y, char *s, int *len)
{
   int c, gap;
   int selitem;
   int first = TRUE;
   int changed;
   int d;

   #ifdef TARGET_CURSES
      int count = 0;
   #endif

   if ((m_x < filebox.x) || (m_x >= filebox.x + filebox.w) ||
       (m_y < filebox.y) || (m_y >= filebox.y + filebox.h) || 
       (m_b & 2))
      return ESC;

   if (filebox.count <= 0)
      return 0;

   do {
      delay(10);

      selitem = -1;
      changed = d = FALSE;

      if (mouse_inside_list(&filebox)) {
	 filebox.current = get_mouse_item(&filebox); 
	 if (filebox.current >= filebox.count)
	    filebox.current = filebox.count - 1;
	 else
	    selitem = filebox.current;
	 changed = TRUE;
      }
      else {
	 if ((m_y < filebox.y + filebox.yoff) && (filebox.scroll > 0)) {
	    filebox.scroll--;
	    filebox.current = filebox.scroll;
	    changed = d = TRUE;
	 }
	 else if ((m_y >= filebox.y + filebox.yoff + filebox.height) &&
		  (filebox.scroll < filebox.count - filebox.height)) {
	    filebox.scroll++;
	    filebox.current = filebox.scroll + filebox.height - 1;
	    if (filebox.current >= filebox.count)
	       filebox.current = filebox.count-1;
	    changed = d = TRUE;
	 }
      }

      if (changed) {
	 hide_mouse(); 
	 draw_contents(&filebox);
	 strcpy(s, filebox.data[filebox.current].text);

	 goto1(x, y);
	 hi_vid();

	 if (strlen(s) > 54) {
	    gap = strlen(s) - 54;

	    pch('.');
	    pch('.');
	    pch('.');
	    pch(' ');

	    mywrite(s+gap+4);
	 }
	 else {
	    gap = 0;

	    mywrite(s);
	 }

	 for (c=strlen(s)-gap; c<54; c++)
	    pch(' ');

	 goto2(x+strlen(s+gap), y);

	 *len = strlen(s);
	 display_mouse();
      }

      if (d)
	 delay(20);

      if ((first) && (selitem >= 0))
	 if (!mouse_dclick(FALSE))
	    if (mouse_dclick(TRUE))
	       return CR;

      first = FALSE;

      refresh_screen();

   #ifdef TARGET_CURSES
      if (d) {
	 if (count++ >= 10)
	    m_b = 0;
      }
      else
	 while (m_b)
   #endif
	    poll_mouse(); 

   } while(m_b);

   clear_keybuf();
   return 0;
}