/[qemacs]/qemacs/shell.c
ViewVC logotype

Diff of /qemacs/shell.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10 by chqrlie, Mon May 9 03:32:19 2005 UTC revision 1.11 by chqrlie, Mon May 9 06:03:07 2005 UTC
# Line 79  static int shell_mode_init(EditState *s, Line 79  static int shell_mode_init(EditState *s,
79      return 0;      return 0;
80  }  }
81    
82  #define PTYCHAR1 "pqrstuvwxyz"  #define PTYCHAR1 "pqrstuvwxyz"
83  #define PTYCHAR2 "0123456789abcdef"  #define PTYCHAR2 "0123456789abcdef"
84    
85  /* allocate one pty/tty pair */  /* allocate one pty/tty pair */
86  static int get_pty(char *tty_str)  static int get_pty(char *tty_str)
# Line 258  static void shell_display_hook(EditState Line 258  static void shell_display_hook(EditState
258      ShellState *s = e->b->priv_data;      ShellState *s = e->b->priv_data;
259    
260      if (e->interactive)      if (e->interactive)
261          e->offset = s->cur_offset;          e->offset = s->cur_offset;
262  }  }
263    
264  static void tty_emulate(ShellState *s, int c)  static void tty_emulate(ShellState *s, int c)
# Line 303  static void tty_emulate(ShellState *s, i Line 303  static void tty_emulate(ShellState *s, i
303                  s->cur_offset = offset1;                  s->cur_offset = offset1;
304              }              }
305              break;              break;
306          case 14:          case 14:
307              s->shifted = 1;              s->shifted = 1;
308              break;              break;
309          case 15:          case 15:
310              s->shifted = 0;              s->shifted = 0;
311              break;              break;
312          case 27:          case 27:
313              s->state = TTY_STATE_ESC;              s->state = TTY_STATE_ESC;
314              break;              break;
315          default:          default:
316              if (c >= 32 || c == 9) {              if (c >= 32 || c == 9) {
317                  int c1, cur_len, len;                  int c1, cur_len, len;
318                  /* CG: assuming ISO-8859-1 characters */                  /* CG: assuming ISO-8859-1 characters */
319                  /* CG: horrible kludge for alternate charset support */                  /* CG: horrible kludge for alternate charset support */
320                  if (s->shifted && c >= 96 && c < 128)                  if (s->shifted && c >= 96 && c < 128)
321                      c += 32;                      c += 32;
322                  /* write char (should factorize with do_char() code */                  /* write char (should factorize with do_char() code */
323                  len = unicode_to_charset(buf1, c, s->b->charset);                  len = unicode_to_charset(buf1, c, s->b->charset);
324                  c1 = eb_nextc(s->b, s->cur_offset, &offset);                  c1 = eb_nextc(s->b, s->cur_offset, &offset);
# Line 347  static void tty_emulate(ShellState *s, i Line 347  static void tty_emulate(ShellState *s, i
347              s->nb_esc_params = 0;              s->nb_esc_params = 0;
348              s->state = TTY_STATE_CSI;              s->state = TTY_STATE_CSI;
349          } else {          } else {
350              /* CG: should deal with other sequences:              /* CG: should deal with other sequences:
351               * ansi: hts=\EH, s0ds=\E(B, s1ds=\E)B, s2ds=\E*B, s3ds=\E+B,               * ansi: hts=\EH, s0ds=\E(B, s1ds=\E)B, s2ds=\E*B, s3ds=\E+B,
352               * linux: hts=\EH, rc=\E8, ri=\EM, rs1=\Ec\E]R, sc=\E7,               * linux: hts=\EH, rc=\E8, ri=\EM, rs1=\Ec\E]R, sc=\E7,
353               * vt100: enacs=\E(B\E)0, hts=\EH, rc=\E8, ri=\EM$<5>,               * vt100: enacs=\E(B\E)0, hts=\EH, rc=\E8, ri=\EM$<5>,
354               *        rmkx=\E[?1l\E>,               *        rmkx=\E[?1l\E>,
355               *        rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7,               *        rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7,
356               *        smkx=\E[?1h\E=,               *        smkx=\E[?1h\E=,
357               * xterm: enacs=\E(B\E)0, hts=\EH, is2=\E[!p\E[?3;4l\E[4l\E>,               * xterm: enacs=\E(B\E)0, hts=\EH, is2=\E[!p\E[?3;4l\E[4l\E>,
358               *        rc=\E8, ri=\EM, rmkx=\E[?1l\E>, rs1=\Ec,               *        rc=\E8, ri=\EM, rmkx=\E[?1l\E>, rs1=\Ec,
359               *        rs2=\E[!p\E[?3;4l\E[4l\E>, sc=\E7, smkx=\E[?1h\E=,               *        rs2=\E[!p\E[?3;4l\E[4l\E>, sc=\E7, smkx=\E[?1h\E=,
360               */               */
361              switch (c) {              switch (c) {
362              case '(':              case '(':
363              case ')':              case ')':
364              case '*':              case '*':
365              case '+':              case '+':
366              case ']':              case ']':
367                  s->esc1 = c;                  s->esc1 = c;
368                  s->state = TTY_STATE_ESC2;                  s->state = TTY_STATE_ESC2;
369                  break;                  break;
370              case 'H':   // hts              case 'H':   // hts
371              case '7':   // sc              case '7':   // sc
372              case '8':   // rc              case '8':   // rc
373              case 'M':   // ri              case 'M':   // ri
374              case 'c':   // rs1              case 'c':   // rs1
375              case '>':   // rmkx, is2, rs2              case '>':   // rmkx, is2, rs2
376              case '=':   // smkx              case '=':   // smkx
377                  // XXX: do these                  // XXX: do these
378              default:              default:
379                  s->state = TTY_STATE_NORM;                  s->state = TTY_STATE_NORM;
380                  break;                  break;
381              }              }
382          }          }
383          break;          break;
384      case TTY_STATE_ESC2:      case TTY_STATE_ESC2:
385          s->state = TTY_STATE_NORM;          s->state = TTY_STATE_NORM;
386  #define ESC2(c1,c2)  (((c1)<<8)|((unsigned char)c2))  #define ESC2(c1,c2)  (((c1)<<8)|((unsigned char)c2))
387          switch (ESC2(s->esc1, c)) {          switch (ESC2(s->esc1, c)) {
388          case ESC2('(','B'):          case ESC2('(','B'):
389          case ESC2(')','B'):          case ESC2(')','B'):
390          case ESC2('(','0'):          case ESC2('(','0'):
391          case ESC2(')','0'):          case ESC2(')','0'):
392          case ESC2('*','B'):          case ESC2('*','B'):
393          case ESC2('+','B'):          case ESC2('+','B'):
394          case ESC2(']','R'):          case ESC2(']','R'):
395              /* XXX: ??? */              /* XXX: ??? */
396              break;              break;
397          }          }
398  #undef ESC2  #undef ESC2
399          break;          break;
400      case TTY_STATE_CSI:      case TTY_STATE_CSI:
401          if (c >= '0' && c <= '9') {          if (c >= '0' && c <= '9') {
402              if (s->nb_esc_params < MAX_ESC_PARAMS) {              if (s->nb_esc_params < MAX_ESC_PARAMS) {
# Line 573  static void shell_read_cb(void *opaque) Line 573  static void shell_read_cb(void *opaque)
573          return;          return;
574            
575      for (i = 0; i < len; i++)      for (i = 0; i < len; i++)
576          tty_emulate(s, buf[i]);          tty_emulate(s, buf[i]);
577    
578      /* now we do some refresh */      /* now we do some refresh */
579      edit_display(qs);      edit_display(qs);
# Line 653  static void shell_close(EditBuffer *b) Line 653  static void shell_close(EditBuffer *b)
653  }  }
654    
655  EditBuffer *new_shell_buffer(const char *name, const char *path,  EditBuffer *new_shell_buffer(const char *name, const char *path,
656                               const char **argv, int is_shell)                               const char **argv, int is_shell)
657  {  {
658      ShellState *s;      ShellState *s;
659      EditBuffer *b, *b_color;      EditBuffer *b, *b_color;
# Line 705  EditBuffer *new_shell_buffer(const char Line 705  EditBuffer *new_shell_buffer(const char
705      return b;      return b;
706  }  }
707    
   
708  static void do_shell(EditState *e)  static void do_shell(EditState *e)
709  {  {
710      EditBuffer *b;      EditBuffer *b;
# Line 735  void shell_move_left_right(EditState *e, Line 734  void shell_move_left_right(EditState *e,
734  {  {
735      if (e->interactive) {      if (e->interactive) {
736          ShellState *s = e->b->priv_data;          ShellState *s = e->b->priv_data;
737          tty_write(s, dir > 0 ? "\033[C" : "\033[D", -1);          tty_write(s, dir > 0 ? "\033[C" : "\033[D", -1);
738      } else {      } else {
739          text_move_left_right_visual(e, dir);          text_move_left_right_visual(e, dir);
740      }      }
# Line 745  void shell_move_word_left_right(EditStat Line 744  void shell_move_word_left_right(EditStat
744  {  {
745      if (e->interactive) {      if (e->interactive) {
746          ShellState *s = e->b->priv_data;          ShellState *s = e->b->priv_data;
747          tty_write(s, dir > 0 ? "\033f" : "\033b", -1);          tty_write(s, dir > 0 ? "\033f" : "\033b", -1);
748      } else {      } else {
749          text_move_word_left_right(e, dir);          text_move_word_left_right(e, dir);
750      }      }
# Line 755  void shell_move_up_down(EditState *e, in Line 754  void shell_move_up_down(EditState *e, in
754  {  {
755      if (e->interactive) {      if (e->interactive) {
756          ShellState *s = e->b->priv_data;          ShellState *s = e->b->priv_data;
757          tty_write(s, dir > 0 ? "\033[B" : "\033[A", -1);          tty_write(s, dir > 0 ? "\033[B" : "\033[A", -1);
758      } else {      } else {
759          text_move_up_down(e, dir);          text_move_up_down(e, dir);
760      }      }
# Line 774  void shell_move_bol(EditState *e) Line 773  void shell_move_bol(EditState *e)
773  {  {
774      if (e->interactive) {      if (e->interactive) {
775          ShellState *s = e->b->priv_data;          ShellState *s = e->b->priv_data;
776          tty_write(s, "\001", -1); /* Control-A */          tty_write(s, "\001", -1); /* Control-A */
777      } else {      } else {
778          text_move_bol(e);          text_move_bol(e);
779      }      }
# Line 784  void shell_move_eol(EditState *e) Line 783  void shell_move_eol(EditState *e)
783  {  {
784      if (e->interactive) {      if (e->interactive) {
785          ShellState *s = e->b->priv_data;          ShellState *s = e->b->priv_data;
786          tty_write(s, "\005", -1); /* Control-E */          tty_write(s, "\005", -1); /* Control-E */
787      } else {      } else {
788          text_move_eol(e);          text_move_eol(e);
789      }      }
# Line 885  static void do_compile_error(EditState * Line 884  static void do_compile_error(EditState *
884      if ((b = eb_find("*compilation*")) == NULL      if ((b = eb_find("*compilation*")) == NULL
885      &&  (b = eb_find("*shell*")) == NULL      &&  (b = eb_find("*shell*")) == NULL
886      &&  (b = eb_find("*errors*")) == NULL) {      &&  (b = eb_find("*errors*")) == NULL) {
887          put_status(s, "No compilation buffer");          put_status(s, "No compilation buffer");
888          return;          return;
889      }      }
890      /* find next/prev error */      /* find next/prev error */
891      offset = error_offset;      offset = error_offset;
# Line 983  static CmdDef shell_commands[] = { Line 982  static CmdDef shell_commands[] = {
982  /* compilation commands */  /* compilation commands */
983  static CmdDef compile_commands[] = {  static CmdDef compile_commands[] = {
984      CMD_( KEY_CTRLX(KEY_CTRL('e')), KEY_NONE, "compile", do_compile,      CMD_( KEY_CTRLX(KEY_CTRL('e')), KEY_NONE, "compile", do_compile,
985            "s{Compile command: }|compile|")            "s{Compile command: }|compile|")
986      CMD1( KEY_CTRLX(KEY_CTRL('p')), KEY_NONE, "previous-error",      CMD1( KEY_CTRLX(KEY_CTRL('p')), KEY_NONE, "previous-error",
987            do_compile_error, -1)            do_compile_error, -1)
988      CMD1( KEY_CTRLX(KEY_CTRL('n')), KEY_NONE, "next-error",      CMD1( KEY_CTRLX(KEY_CTRL('n')), KEY_NONE, "next-error",

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26