Exemple #1
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPredInstance, LPSTR lpCmdLine, int nShowCmd)
{
	int n = 1;
	while(1)
	{
		Sleep(6000);
		capture_screen(n++);
		
	}
	return 0;
}
void app_scenario1::draw_frame()
{
	base::frame_context *ctx = pop_frame_context_from_pool();

	static bool first=true;

	if(!ctx->check_fence())
		printf("fence incomplete!\n");

	//printf("scene buffer handle: %.2u, ptr %p\n", ctx->_scene_vbo, ctx->_scene_data_ptr);

	app::begin_frame(ctx);

	app::create_perspective_matrix(ctx);
	app::update_camera(ctx);

	//app::prepare_showtime(ctx);
	process_captured_screen();

	ctx->map_scene();

	static char* cached_scene_data_ptr;
	static int cached_scene_data_ptr_size;

	//memset(ctx->_scene_data_ptr, 0, ctx->_scene_data_ptr_size);
	_scene->frustum_check(ctx);
	_scene->upload_blocks_to_gpu(SRC_LOCATION, ctx);

	/*static int counter = 100;
	if(counter-- < 0)
		memset(ctx->_scene_data_ptr, 0, ctx->_scene_data_ptr_size);*/

	ctx->flush_scene_data();

	/*_frame_context->map_scene();
	_scene->frustum_check(_frame_context.get());
	_scene->upload_blocks_to_gpu(SRC_LOCATION, _frame_context.get());
	_frame_context->flush_scene_data();*/

	scene::render_blocks(ctx);
	//app::render_showtime(ctx);
	
	ctx->map_canvas();
	app::end_frame(ctx);
	ctx->flush_canvas_data();

	capture_screen();

	ctx->put_fence();

	push_frame_context_to_pool(ctx);
}
Exemple #3
0
int main(int argc, char **argv)
{
    HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL);

    InitCommonControls();
    setup_console();

    // default screenshot filename
    char *filename = NULL;

    // coordinates
    bool use_coords = false;
    int x1, y1, x2, y2;

    // parse command line
    int i;

    // parse options
    for (i=1; i<argc; i++) {
        if (argv[i][0] != '-')
            // argument is not an option
            break;

        else if (strcmp(argv[i], "-f") == 0 ||
                 strcmp(argv[i], "--fullscreen") == 0)
        {
            RECT rect;
            get_screen_rect(&rect);
            x1 = rect.left;
            y1 = rect.top;
            x2 = rect.right;
            y2 = rect.bottom;
            use_coords = true;
        }

        else if (strcmp(argv[i], "-c") == 0 ||
                 strcmp(argv[i], "--coords") == 0)
        {
            if (i+1 >= argc) {
                printf("error: expected argument for -c,--coord\n");
                usage();
                return 1;
            }

            if (sscanf(argv[++i], "%d,%d,%d,%d", &x1, &y1, &x2, &y2) != 4) {
                printf("error: expected 4 comma separated integers\n");
                usage();
                return 1;
            }

            use_coords = true;
        }

        else if (strcmp(argv[i], "-v") == 0 ||
                 strcmp(argv[i], "--version") == 0)
        {
            // display version information
            version();
            return 1;
        }

        else if (strcmp(argv[i], "-h") == 0 ||
                 strcmp(argv[i], "--help") == 0)
        {
            // display help info
            usage();
            return 1;
        }

        else {
            printf("error: unknown option '%s'\n", argv[i]);
            usage();
            return 1;
        }
    }

    // argument after options is a filename
    if (i < argc)
        filename = argv[i];



    // create screenshot window
    BoxCutterWindow win(hInstance, "BoxCutter", filename);


    if (use_coords) {
        win.show();
    } else {
        // manually acquire coordinates
        win.show();
        win.maximize();
        win.activate();

        main_loop(&win);
        if (win.have_coords()) {
            win.get_coords(&x1, &y1, &x2, &y2);
        } else {
            printf("error: cannot retrieve screenshot coordinates\n");
            return 1;
        }
    }

    // display screenshot coords
    printf("screenshot coords: (%d,%d)-(%d,%d)\n", x1, y1, x2, y2);


    // save bitmap
    if (filename) {
        // save to file
        if (!capture_screen(filename, x1, y1, x2, y2))
        {
            MessageBox(win.get_handle(), "Cannot save screenshot",
                       "Error", MB_OK);
            return 1;
        }

        printf("screenshot saved to file: %s\n", filename);
    } else {
        // save to clipboard
        if (!capture_screen_clipboard(win.get_handle(), x1, y1, x2, y2))
        {
            MessageBox(win.get_handle(), "Cannot save screenshot to clipboard",
                       "Error", MB_OK);
            return 1;
        }

        printf("screenshot saved to clipboard.\n");
    }

    win.close();

    return 0;
}
Exemple #4
0
int 
more(char *fpath, int promptend)
{
  extern char *strcasestr();
  static char *head[4] = {"§@ªÌ", "¼ÐÃD", "®É¶¡", "Âà«H"};
  char *ptr, *word, buf[1024], *ch1;
  struct stat st;
  FILE *fp;
  usint pagebreak[MAXPAGES], pageno, lino;
  int line, ch, viewed, pos, numbytes;
  int header = 0;
  int local = 0;
  char search_char0 = 0;
  static char search_str[81] = "";
  typedef char *(*FPTR) ();
  static FPTR fptr;
  int searching = 0;
  int scrollup = 0;
  char *http[80] = {
    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
  /* Ptt */
  char pagemode = 0;
  char pagecount = 0;

  inmore = 1;
  memset(pagebreak, 0, sizeof(pagebreak));
  if (*search_str)
    search_char0 = *search_str;
  *search_str = 0;
  if (!(fp = fopen(fpath, "r")))
  {
    inmore = 0;
    return -1;
  }

  if (fstat(fileno(fp), &st))
  {
    inmore = 0;
    fclose(fp);
    return -1;
  }

  pagebreak[0] = pageno = viewed = line = pos = 0;
  clear();

  while ((numbytes = readln(fp, buf)) || (line == t_lines))
  {
    if (scrollup)
    {
      rscroll();
      move(0, 0);
    }
    if (numbytes)		/* ¤@¯ë¸ê®Æ³B²z */
    {
      if (!viewed)		/* begin of file */
      {
	if (showansi)		/* header processing */
	{
	  if (!strncmp(buf, str_author1, LEN_AUTHOR1))
	  {
	    line = 3;
	    word = buf + LEN_AUTHOR1;
	    local = 1;
	  }
	  else if (!strncmp(buf, str_author2, LEN_AUTHOR2))
	  {
	    line = 4;
	    word = buf + LEN_AUTHOR2;
	  }

	  while (pos < line)
	  {
	    if (!local)
	      str_decode(word);

	    if (!pos && ((ptr = strstr(word, str_post1)) ||
			 (ptr = strstr(word, str_post2))))
	    {
	      ptr[-1] = '\0';

	      /* hialan §ïÃC¦â */
	      clrtoeol();
	      prints("¢~\033[46;37m%s\033[m%-55.55s%.4s\033[1;33m%-13s\033[36m¢¡\n", head[0], word, ptr, ptr + 5);
	    }
	    else if (pos < (local ? 3 : 4))
	    {
	      clrtoeol();
	      prints("¢x\033[46;37m%s\033[m%-72.72s¢x\033[m\n", head[pos], word);
	    }

	    viewed += numbytes;
	    numbytes = readln(fp, buf);

	    if (!pos && viewed >= 79)	/* ²Ä¤@¦æ¤Óªø¤F */
	    {
	      if (memcmp(buf, head[1], 2))	/* ²Ä¤G¦æ¤£¬O [¼Ð....] */
	      {
		viewed += numbytes;	/* Ū¤U¤@¦æ¶i¨Ó³B²z */
		numbytes = readln(fp, buf);
	      }
	    }

	    pos++;
	  }
	  if (pos)
	  {
	    header = 1;

	    outs("¢¢¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w\033[0;30;47m y)¦^À³  /)·j´M¤å¦r  =[]<>)¥DÃD¦¡¾\\Ū \033[0;1;36m¢£\n");

	    line = pos = (local ? 4 : 5);
	  }
	}
	lino = pos;
	word = NULL;
      }
      /* ¡°³B²z¤Þ¥ÎªÌ & ¤Þ¨¥ */

      if ((buf[1] == ' ') && (buf[0] == ':' || buf[0] == '>'))
	word = "";
      if ((buf[1] == ' ') && (buf[0] == ':' || buf[0] == '>') && (buf[2] == ':' || buf[2] == '>'))
	word = "";
      if ((buf[0] == '¡' && buf[1] == '°') || !strncmp(buf, "==>", 3))
	word = "";

      ch1 = buf;
      while (1)			/* Ptt */
      {
	int i;
	char e, *ch2;
	if (ch2 = strstr(ch1, "gopher://"));
	else if (ch2 = strstr(ch1, "mailto:"));
	else if (ch2 = strstr(ch1, "board://"));	/* ¤ä´©ª½±µ¶i¤J¬ÝªO */
	else
	  break;

	for (e = 0; ch2[e] != ' ' && ch2[e] != '\n' && ch2[e] != '\0'
	     && ch2[e] != '"' && ch2[e] != ';' && ch2[e] != ']'; e++);
	for (i = 0; http[i] && i < 80; i++)
	  if (!strncmp(http[i], ch2, e) && http[e] == 0)
	    break;
	if (!http[i])
	{
	  http[i] = (char *)malloc(e + 1);
	  strncpy(http[i], ch2, e);
	  http[i][e] = 0;
	  pagecount++;
	}
	ch1 = &ch2[7];
      }

      if (word)
	outs(word);
      {
	char msg[500], *pos;

	if (*search_str && (pos = fptr(buf, search_str)))
	{
	  char SearchStr[41];
	  char buf1[100], *pos1;

	  strncpy(SearchStr, pos, strlen(search_str));
	  SearchStr[strlen(search_str)] = 0;
	  searching = 0;
	  sprintf(msg, "%.*s%s", pos - buf, buf,
		  SearchStr);
	  while (pos = fptr(pos1 = pos + strlen(search_str), search_str))
	  {
	    sprintf(buf1, "%.*s%s", pos - pos1, pos1, SearchStr);
	    strcat(msg, buf1);
	  }
	  strcat(msg, pos1);
	  outs(Ptt_prints(msg, NO_RELOAD));
	}
	else
	{
	  outs(Ptt_prints(buf, NO_RELOAD));
	}
      }
      if (word)
      {
	outs("");
	word = NULL;
      }
      outc('\n');

      if (beep)
      {
	bell();
	beep = 0;
      }

      if (line < b_lines)	/* ¤@¯ë¸ê®ÆŪ¨ú */
	line++;

      if (line == b_lines && searching == -1)
      {
	if (pageno > 0)
	  fseek(fp, (off_t) (viewed = pagebreak[--pageno]), SEEK_SET);
	else
	  searching = 0;
	lino = pos = line = 0;
	clear();
	continue;
      }

      if (scrollup)
      {
	move(line = b_lines, 0);
	clrtoeol();
	for (pos = 1; pos < b_lines; pos++)
	  viewed += readln(fp, buf);
      }
      else if (pos == b_lines)	/* ±²°Ê¿Ã¹õ */
	scroll();
      else
	pos++;


      if (!scrollup && ++lino >= b_lines && pageno < MAXPAGES - 1)
      {
	pagebreak[++pageno] = viewed;
	lino = 1;
      }

      if (scrollup)
      {
	lino = scrollup;
	scrollup = 0;
      }
      viewed += numbytes;	/* ²Ö­pŪ¹L¸ê®Æ */
    }
    else
      line = b_lines;		/* end of END */


    if (promptend && (!searching && line == b_lines || viewed == st.st_size))
    {
      move(b_lines, 0);
      if (viewed == st.st_size)
      {
	if (searching == 1)
	  searching = 0;
      }
      else if (pageno == 1 && lino == 1)
      {
	if (searching == -1)
	  searching = 0;
      }
      prints("%s  ÂsÄý P.%d(%d%%)  ", COLOR2, pageno, (viewed * 100) / st.st_size);
      prints("%s                 ¡ö¡ô¡õ¡÷|PgUp|PgDn|Home|End)¾ÉÄý  h)»¡©ú \033[m", COLOR3);

      move(b_lines, 0);		/* ¸Ñ¨Mª½±µ¸õ¨ì¬ÝªOªºBug */
      while (line == b_lines || (line > 0 && viewed == st.st_size))
      {
	switch (ch = igetkey())
	{
	case 'h':
	case 'H':
	case '?':
	  show_file("etc/help/MORE.help", 0, 24, ONLY_COLOR);
	  pressanykey_old(NULL);
	  if (pageno)
	    pageno--;
	  lino = line = 0;
	  break;
	case ':':
	  {
	    char buf[10];
	    int i = 0;

	    getdata(b_lines - 1, 0, "Goto Page: ", buf, 5, DOECHO, 0);
	    sscanf(buf, "%d", &i);
	    if (0 < i && i < MAXPAGES && (i == 1 || pagebreak[i - 1]))
	      pageno = i - 1;
	    else if (pageno)
	      pageno--;
	    lino = line = 0;
	    break;
	  }

	case '/':
	  {
	    char ans[4] = "n";
	    *search_str = search_char0;
	    getdata(b_lines - 1, 0, "[·j´M]ÃöÁä¦r:", search_str, 40, DOECHO, 0);
	    if (*search_str)
	    {
	      searching = 1;
	      if (getdata(b_lines - 1, 0, "°Ï¤À¤j¤p¼g(Y/N/Q)? [N] ", ans, 4, LCECHO, 0) && *ans == 'y')
		fptr = strstr;
	      else
		fptr = strcasestr;
	    }
	    if (*ans == 'q')
	      searching = 0;
	    if (pageno)
	      pageno--;
	    lino = line = 0;
	    break;
	  }
	case 'n':
	  if (*search_str)
	  {
	    searching = 1;
	    if (pageno)
	      pageno--;
	    lino = line = 0;
	  }
	  break;
	case 'N':
	  if (*search_str)
	  {
	    searching = -1;
	    if (pageno)
	      pageno--;
	    lino = line = 0;
	  }
	  break;
	case 'r':
	case 'R':
	case 'Y':
	case 'y':
	case 'A':
	case 'a':
	case 'F':
	case 'B':
	case KEY_LEFT:
	case 'q':
	case 'b':
	case 'f':
	case ']':		/* Kaede ¬°¤F¥DÃD¾\Ū¤è«K */
	case '[':		/* Kaede ¬°¤F¥DÃD¾\Ū¤è«K */
	case '=':		/* Kaede ¬°¤F¥DÃD¾\Ū¤è«K */
	  fclose(fp);
	  inmore = 0;
	  return ch;
	  
	case Ctrl('F'):
	case KEY_PGDN:
	  line = 1;
	  break;
	case 't':
	  if (viewed == st.st_size)
	  {			/* ch ']' */
	    fclose(fp);
	    inmore = 0;
	    return ']';
	  }
	  line = 1;
	  break;
	case ' ':
	  if (viewed == st.st_size)
	  {			/* ch 'f' */
	    fclose(fp);
	    inmore = 0;
	    return 'f';
	  }
	  line = 1;
	  break;
	case KEY_RIGHT:
	  if (viewed == st.st_size)
	  {			/* ch 'q' */
	    fclose(fp);
	    inmore = 0;
	    return 'q';
	  }
	  line = 1;
	  pagemode = 0;
	  break;
	case '\r':
	case '\n':
	  if (pagemode)
	  {
	    more_web(http[pagemode - 1], YEA);
	    /* pagebreak[0] = pageno = viewed = line = pos = 0; */
	    pagemode = 0;
	    *search_str = 0;
	    if (pageno)
	      pageno--;
	    lino = line = 0;
	    break;
	  }

	case KEY_DOWN:
	  if (viewed == st.st_size ||
	      promptend == 2 && (ch == '\r' || ch == '\n'))
	  {					/* ch 'f' */
	    fclose(fp);		
	    inmore = 0;
	    return 'f';
	  }
	  line = t_lines - 2;
	  break;

	case '$':
	case 'G':
	case KEY_END:
	  line = t_lines;
	  break;

	case '0':
	case 'g':
	case KEY_HOME:
	  pageno = line = 0;
	  break;

	case 'E':
	  if (strcmp(fpath, "etc/ve.hlp"))
	  {			/* ch 'q' */
	    fclose(fp);
	    inmore = 0;
	    vedit(fpath, HAS_PERM(PERM_SYSOP) ? 0 : 2);
	    return 'q';
	  }
	  break;

	case KEY_ESC:
	  if (KEY_ESC_arg == 'n')
	  {
	    edit_note();
	    if (pageno)
	      pageno--;
	    lino = line = 0;
	  }
	  else if (KEY_ESC_arg == 'c')
	    capture_screen();
	  break;

	case Ctrl('I'):
	  if (!pagecount)
	    break;
	  pagemode = (pagemode % pagecount) + 1;
	  strcpy(search_str, http[pagemode - 1]);
	  fptr = strstr;
	  if (pageno)
	    pageno--;
	  lino = line = 0;
	  break;

	case KEY_UP:
	  line = -1;
	  break;

	case Ctrl('B'):
	case KEY_PGUP:
	  if (pageno > 1)
	  {
	    if (lino < 2)
	      pageno -= 2;
	    else
	      pageno--;
	    lino = line = 0;
	  }
	  else if (pageno && lino > 1)
	    pageno = line = 0;
	  break;
	case Ctrl('H'):
	  if (pageno > 1)
	  {
	    if (lino < 2)
	      pageno -= 2;
	    else
	      pageno--;
	    lino = line = 0;
	  }
	  else if (pageno && lino > 1)
	    pageno = line = 0;
	  else
	  {			/* ch 'b' */
	    fclose(fp);
	    inmore = 0;
	    return 'b';
	  }
	}
      }

      if (line > 0)
      {
	move(b_lines, 0);
	clrtoeol();
	refresh();
      }
      else if (line < 0)
      {				/* Line scroll up */
	if (pageno <= 1)
	{
	  if (lino == 1 || !pageno)
	  {			/* ch 'b' */
	    fclose(fp);
	    inmore = 0;
	    return 'b';
	  }

	  /* ­¶¤º¤W±² sheng 20020113 */
	  if (header && lino <= 6 - local)
	  {
	    fseek(fp, (off_t) (viewed = pagebreak[scrollup = lino = pageno = 0] = 0), SEEK_SET);
	    clear();
	  }
	}

	if (pageno && lino > 1)
	{
	  line = lino - 2;
	  if (pageno == 1 && header)
	    line = lino - 3;

	  scrollup = lino - 1;
	  fseek(fp, (off_t) (viewed = pagebreak[pageno - 1]), SEEK_SET);
	  while (line--)
	    viewed += readln(fp, buf);
	}
	else if (pageno > 1)
	{
	  scrollup = b_lines - 1;

	  line = b_lines - 2;
	  if (pageno == 2 && header)
	    line = b_lines - 3;

	  fseek(fp, (off_t) (viewed = pagebreak[--pageno - 1]), SEEK_SET);
	  while (line--)
	    viewed += readln(fp, buf);
	}
	line = pos = 0;
      }
      else
      {
	pos = 0;
	fseek(fp, (off_t) (viewed = pagebreak[pageno]), SEEK_SET);
	clear();
      }
    }
  }

  fclose(fp);
  if (promptend)
  {
    pressanykey(NULL);
    clear();
  }
  else
    outs(reset_color);

  inmore = 0;
  return 'q';		/* ch 'q'*/
}
Exemple #5
0
int 
getdata(int line, int col, char *prompt, char *buf, int len, int echo, char *ans)
{
  register int ch;
  int clen;
  int x, y;
  int off_set = 0; /*add color*/
#define MAXLASTCMD 6
  static char lastcmd[MAXLASTCMD][80];

  if (prompt)
  {
    move(line, col);
    clrtoeol();
    outs(prompt);
    off_set=offset_count(prompt); /*add color*/
  }
  else
    clrtoeol();

  if (echo == NOECHO)
  {
    len--;              /* 下面這段程式碼是沒有反白 (!echo) */
    clen = 0;
    while ((ch = igetkey()) != '\r')
    {
      if (ch == '\n')
        break;
      if (ch == KEY_BKSP || ch == Ctrl('H'))
      {
        if (!clen)
          bell();
        else
          clen--;
          
        continue;
      }

#ifdef BIT8
      if (!isprint2(ch))
#else
      if (!isprint(ch))
#endif
      {
        continue;
      }

      if (clen >= len)
        continue;

      buf[clen++] = ch;
    }
    buf[clen] = '\0';
    outc('\n');
    oflush();
  }
  else
  {
   int cmdpos = MAXLASTCMD -1;
   int currchar = 0;
   int keydown;
   int dirty, i;

    getyx(&y, &x);
    x=x-off_set;  /*add color by hialan*/
    standout();
    for (clen = len; clen; clen--)
      outc(' ');
    standend();

    if (ans != NULL) 
    {
       str_ansi(buf, ans, len);
       move(y, x);
       edit_outs(buf);
       clen = currchar = strlen(buf);
    }
    
    /* 因為 buf 有可能會和 ans 相同 , 所以先把初始字串完成後 */
    /* 再根據 clen 將字串後面清空 */
    memset(buf+clen, 0, len-clen);

    len--;
    dirty = 0;
    while (move(y, x + currchar), (ch = igetkey()) != '\r')
    {
       keydown = 0;
       switch (ch) 
       {
       case Ctrl('Y'): 
       {
          if (clen && dirty) 
          {
             for (i = MAXLASTCMD - 1; i; i--)
                strcpy(lastcmd[i], lastcmd[i - 1]);
             strlcpy(lastcmd[0], buf, sizeof(lastcmd[0]) );
          }

          move(y, x);
          for (clen = len; clen; clen--)
            outc(' ');
          memset(buf, '\0', len);
          clen = currchar = 0;
          continue;
       }

       case KEY_DOWN:
       case Ctrl('N'):
          keydown = 1;
       case Ctrl('P'):
       case KEY_UP: 
       {
          if (clen && dirty) 
          {
             for (i = MAXLASTCMD - 1; i; i--)
                strcpy(lastcmd[i], lastcmd[i - 1]);
             strlcpy(lastcmd[0], buf, sizeof(lastcmd[0]) );
          }

          i = cmdpos;
          do 
          {
             if (keydown)
                --cmdpos;
             else
                ++cmdpos;
             if (cmdpos < 0)
                cmdpos = MAXLASTCMD - 1;
             else if (cmdpos == MAXLASTCMD)
                cmdpos = 0;
          } while (cmdpos != i && (!*lastcmd[cmdpos] || !strncmp(buf, lastcmd[cmdpos], len)));
          if (cmdpos == i)
             continue;

          strncpy(buf, lastcmd[cmdpos], len);
          buf[len] = 0;

          move(y, x);                   /* clrtoeof */
          for (i = 0; i <= clen; i++)
             outc(' ');
          move(y, x);

          if (echo == PASS)
            passwd_outs(buf);
          else
            edit_outs(buf);
          clen = currchar = strlen(buf);
          dirty = 0;
          continue;
       }
       case KEY_ESC:
         if(currutmp)
         {
           if (KEY_ESC_arg == 'c')
              capture_screen();
              
           if (KEY_ESC_arg == 'n')
              edit_note();
         }
         continue;

       /* yagami.000504 : 游標可到最前或最後 */ 
       case Ctrl('A'):
       case KEY_HOME:
         currchar = 0;
         break;
       case Ctrl('E'):
       case KEY_END:
         currchar = clen;
         break;

       case KEY_LEFT:
          if (currchar)
             --currchar;
          continue;
       case KEY_RIGHT:
          if (buf[currchar])
             ++currchar;
          continue;
       case Ctrl('K'):
       {
         buf[currchar] = 0;
         move(y, x + currchar);
         for (i = currchar; i < clen; i++)
            outc(' ');
         clen = currchar;
         dirty = 1;
         continue;
       }
 
       case Ctrl('D'): 
       {
         if (buf[currchar]) 
         {
            clen--;
            for (i = currchar; i <= clen; i++)
               buf[i] = buf[i + 1];
            move(y, x + clen);
            outc(' ');
            move(y, x);
            if (echo == PASS)
              passwd_outs(buf);
            else
              edit_outs(buf);
            dirty = 1;
         }
         continue;
       }       
       
       case KEY_BKSP:
       case Ctrl('H'):
       {
         if (currchar) 
         {
            currchar--;
            clen--;
            for (i = currchar; i <= clen; i++)
               buf[i] = buf[i + 1];
            move(y, x + clen);
            outc(' ');
            move(y, x);
            if (echo == PASS)
              passwd_outs(buf);
            else
              edit_outs(buf);
            dirty = 1;
         }
         continue;
       }       
       
       case Ctrl('I'):
         if(currstat != IDLE && !(currutmp->mode == 0 &&
            (currutmp->chatid[0] == 2 || currutmp->chatid[0] == 3))) 
         {
           t_idle();
         }
         continue;

       } /* switch(ch) */

      if (ch == '\n' || ch == '\r')
         break;

      if (!(isprint2(ch)) || clen >= len || x + clen >= scr_cols)
        continue;

      if (buf[currchar]) 
      {     		                /* insert */
         for (i = currchar; buf[i] && i < len && i < 80; i++)
            ;
         buf[i + 1] = 0;
         for (; i > currchar; i--)
            buf[i] = buf[i - 1];
      }
      else                              /* append */
         buf[currchar + 1] = '\0';

      buf[currchar] = ch;
      move(y, x + currchar);
      if (echo == PASS)
        passwd_outs(buf + currchar);
      else
      /* shakalaca.990422: 原本只有下面那行, 這是為了輸入 passwd 有反白 */
        edit_outs(buf + currchar);
      currchar++;
      clen++;
      dirty = 1;
    }
    buf[clen] = '\0';

    if (clen > 1 && echo != PASS) 
    /* shaklaaca.990514: ^^^^^^^ 不讓輸入的 password 留下紀錄 */
    {
       for (cmdpos = MAXLASTCMD - 1; cmdpos; cmdpos--)
          strcpy(lastcmd[cmdpos], lastcmd[cmdpos - 1]);
       strlcpy(lastcmd[0], buf, sizeof(lastcmd[0]) );
    }

    move(y, x + clen);
    outc('\n');
    refresh();
  }

  if(echo == LCECHO)
    buf[0] = tolower(buf[0]);

  return clen;
}