utashiro@sran84.sra.JUNET (Kazumasa Utashiro) (01/06/89)
Description: * Added history insertion *** /tmp/,RCSt1012719 Fri Jan 6 08:50:41 1989 --- fep_funcs.c Fri Nov 25 20:52:14 1988 *************** *** 2,8 #ifndef lint static char rcsid[]= ! "$Header: fep_funcs.c,v 4.3 88/08/28 14:36:35 utashiro Exp $ (SRA)"; #endif lint #include <stdio.h> --- 2,8 ----- #ifndef lint static char rcsid[]= ! "$Header: fep_funcs.c,v 4.4 88/11/25 20:52:09 utashiro Exp $ (SRA)"; #endif lint #include <stdio.h> *************** *** 64,69 "Get next history"}, {previous_history, "previous-history", "Get previous history"}, {ignore, "ignore", "Ignore"}, {delete_line, "delete-line", --- 64,75 ----- "Get next history"}, {previous_history, "previous-history", "Get previous history"}, + {insert_next_history, "insert-next-history", + "Insert next history"}, + {insert_previous_history, "insert-previous-history", + "Insert previous history"}, + {insert_current_history, "insert-current-history", + "Insert current history"}, {ignore, "ignore", "Ignore"}, {delete_line, "delete-line", *** /tmp/,RCSt1012745 Fri Jan 6 08:50:51 1989 --- fep_hist.c Fri Nov 25 20:45:42 1988 *************** *** 2,8 #ifndef lint static char rcsid[]= ! "$Header: fep_hist.c,v 4.2 88/08/28 19:15:08 utashiro Exp $ (SRA)"; #endif lint #include <stdio.h> --- 2,8 ----- #ifndef lint static char rcsid[]= ! "$Header: fep_hist.c,v 4.3 88/11/25 20:45:25 utashiro Exp $ (SRA)"; #endif lint #include <stdio.h> *************** *** 85,90 } char * getPreviousHistory() { if (HistorySize <= 0) --- 85,111 ----- } char * + getHistory(num) + int num; + { + if (HistorySize <= 0) + return (0); + + if (num < TopOfHist || TailOfHist <= num) { + return ((char *)0); + } + else { + return (HistoryTable[num % HistorySize]); + } + } + + char * + getCurrentHistory() + { + return (getHistory (CurrentHist)); + } + + char * getPreviousHistory() { if (HistorySize <= 0) *************** *** 97,103 CurrentHist = TailOfHist - 1; else CurrentHist--; ! return (HistoryTable[CurrentHist % HistorySize]); } char * --- 118,124 ----- CurrentHist = TailOfHist - 1; else CurrentHist--; ! return (getCurrentHistory ()); } char * *************** *** 111,133 CurrentHist = TopOfHist; else CurrentHist++; ! return (HistoryTable[CurrentHist % HistorySize]); ! } ! ! char * ! getHistory(num) ! int num; ! { ! ! if (HistorySize <= 0) ! return (0); ! ! if (num < TopOfHist || TailOfHist <= num) { ! return ((char *)0); ! } ! else { ! return (HistoryTable[num % HistorySize]); ! } } getOldestHistNum() --- 132,138 ----- CurrentHist = TopOfHist; else CurrentHist++; ! return (getCurrentHistory ()); } getOldestHistNum() *** /tmp/,RCSt1012759 Fri Jan 6 08:51:00 1989 --- fep_edit.c Wed Dec 28 21:23:39 1988 *************** *** 2,8 #ifndef lint static char rcsid[]= ! "$Header: fep_edit.c,v 4.4 88/08/28 18:57:32 utashiro Exp $ (SRA)"; #endif lint #include <stdio.h> --- 2,8 ----- #ifndef lint static char rcsid[]= ! "$Header: fep_edit.c,v 4.6 88/11/25 20:51:53 utashiro Exp $ (SRA)"; #endif lint #include <stdio.h> *************** *** 66,71 /* esc-H */ {"\\^[H", delete_previous_Word}, /* esc-l */ {"\\^[l", list_file_name}, /* esc-L */ {"\\^[L", list_file_name}, /* esc-esc */ {"\\^[\\^[", expand_file_name}, /* esc-"-" */ {"\\^[-", toggle_through}, /* esc-_ */ {"\\^[_", invoke_shell}, --- 66,76 ----- /* esc-H */ {"\\^[H", delete_previous_Word}, /* esc-l */ {"\\^[l", list_file_name}, /* esc-L */ {"\\^[L", list_file_name}, + /* esc-n */ {"\\^[n", insert_next_history}, + /* esc-N */ {"\\^[N", insert_next_history}, + /* esc-p */ {"\\^[p", insert_previous_history}, + /* esc-P */ {"\\^[P", insert_previous_history}, + /* esc-. */ {"\\^[.", insert_current_history}, /* esc-esc */ {"\\^[\\^[", expand_file_name}, /* esc-"-" */ {"\\^[-", toggle_through}, /* esc-_ */ {"\\^[_", invoke_shell}, *************** *** 792,799 } else #endif KANJI ! if (isctlchar(CommandLine[i])) ! (void) putchar (unctl (CommandLine [i++])); else (void) putchar (CommandLine[i++]); --- 797,806 ----- } else #endif KANJI ! if (isctlchar(CommandLine[i])) { ! (void) putchar (unctl (CommandLine [i])); ! i++; ! } else (void) putchar (CommandLine[i++]); *************** *** 1494,1500 clear_screen() { - if (term_clear) { (void) clear_edit_line (); fputs (term_clear, stdout); --- 1501,1506 ----- clear_screen() { if (term_clear) { (void) clear_edit_line (); fputs (term_clear, stdout); *************** *** 1506,1511 return (0); } /* * Get next history entry */ --- 1512,1520 ----- return (0); } + typedef enum {HOP_INSERT, HOP_REPLACE} HISTOP; + typedef enum {HDIR_PREV, HDIR_CURRENT, HDIR_NEXT} HISTDIR; + /* * Get next history entry */ *************** *** 1511,1519 */ next_history() { ! register char *cp; ! char *getNextHistory (); ! int diff; if ((cp = getNextHistory ()) == (char *)0) { errorBell (); --- 1520,1527 ----- */ next_history() { ! return (serv_history (HOP_REPLACE, HDIR_NEXT)); ! } /* * Get next history entry *************** *** 1515,1536 char *getNextHistory (); int diff; ! if ((cp = getNextHistory ()) == (char *)0) { ! errorBell (); ! return (0); ! } ! diff = howlong (CommandLine, 0) - howlong (cp, 0); ! (void) beginning_of_line (); ! if (isctlchar (CommandLine[0])) ! putchar (BS); ! printS (cp); ! if (diff > 0) { ! repeat (SP, diff); ! repeat (BS, diff); ! } ! (void) strcpy (CommandLine, cp); ! CurrentPosition = strlen (CommandLine); ! return (0); } /* --- 1523,1534 ----- return (serv_history (HOP_REPLACE, HDIR_NEXT)); } ! /* ! * Get next history entry ! */ ! previous_history() ! { ! return (serv_history (HOP_REPLACE, HDIR_PREV)); } /* *************** *** 1534,1539 } /* * Get previous history */ previous_history() --- 1532,1561 ----- } /* + * Insert next history entry + */ + insert_current_history() + { + return (serv_history (HOP_INSERT, HDIR_CURRENT)); + } + + /* + * Insert next history entry + */ + insert_next_history() + { + return (serv_history (HOP_INSERT, HDIR_NEXT)); + } + + /* + * Insert next history entry + */ + insert_previous_history() + { + return (serv_history (HOP_INSERT, HDIR_PREV)); + } + + /* * Get previous history */ serv_history(op, dir) *************** *** 1536,1542 /* * Get previous history */ ! previous_history() { register char *cp; char *getPreviousHistory (); --- 1558,1566 ----- /* * Get previous history */ ! serv_history(op, dir) ! HISTOP op; ! HISTDIR dir; { register char *cp; char *getPreviousHistory (), *getNextHistory (), *getCurrentHistory (); *************** *** 1539,1545 previous_history() { register char *cp; ! char *getPreviousHistory (); int diff; if ((cp = getPreviousHistory ()) == (char *)0) { --- 1563,1569 ----- HISTDIR dir; { register char *cp; ! char *getPreviousHistory (), *getNextHistory (), *getCurrentHistory (); int diff; switch (dir) { *************** *** 1542,1548 char *getPreviousHistory (); int diff; ! if ((cp = getPreviousHistory ()) == (char *)0) { errorBell (); return (0); } --- 1566,1579 ----- char *getPreviousHistory (), *getNextHistory (), *getCurrentHistory (); int diff; ! switch (dir) { ! case HDIR_PREV: cp = getPreviousHistory (); break; ! case HDIR_NEXT: cp = getNextHistory (); break; ! case HDIR_CURRENT: cp = getCurrentHistory (); break; ! default: cp = (char*)0; ! } ! ! if (cp == (char *)0) { errorBell (); return (0); } *************** *** 1547,1563 return (0); } ! diff = howlong (CommandLine, 0) - howlong (cp, 0); ! (void) beginning_of_line (); ! if (isctlchar (CommandLine[0])) ! putchar (BS); ! printS (cp); ! if (diff > 0) { ! repeat (SP, diff); ! repeat (BS, diff); ! } ! (void) strcpy (CommandLine, cp); ! CurrentPosition = strlen (CommandLine); return (0); } --- 1578,1586 ----- return (0); } ! if (op == HOP_REPLACE) ! (void) delete_line (); ! (void) insert_string (cp); return (0); } *** /tmp/,RCSt1012777 Fri Jan 6 08:51:15 1989 --- fep_funcs.h Fri Nov 25 20:52:17 1988 *************** *** 2,8 #ifndef lint # define FEP_FUNCS \ ! "$Header: fep_funcs.h,v 4.3 88/08/28 14:36:39 utashiro Exp $ (SRA)" #endif lint /* --- 2,8 ----- #ifndef lint # define FEP_FUNCS \ ! "$Header: fep_funcs.h,v 4.4 88/11/25 20:52:15 utashiro Exp $ (SRA)" #endif lint /* *************** *** 41,46 int new_line(); int next_history(); int previous_history(); int reprint(); int search_reverse(); int search_forward(); --- 41,49 ----- int new_line(); int next_history(); int previous_history(); + int insert_next_history(); + int insert_previous_history(); + int insert_current_history(); int reprint(); int search_reverse(); int search_forward(); *** /tmp/,RCSt1012795 Fri Jan 6 08:51:23 1989 --- fep_main.c Thu Dec 8 15:44:02 1988 *************** *** 2,8 #ifndef lint static char rcsid[]= ! "$Header: fep_main.c,v 4.3 88/08/28 14:36:44 utashiro Exp $ (SRA)"; #endif lint #include <stdio.h> --- 2,8 ----- #ifndef lint static char rcsid[]= ! "$Header: fep_main.c,v 4.4 88/12/08 15:43:45 utashiro Exp $ (SRA)"; #endif lint #include <stdio.h> *************** *** 300,306 perror ("open"); while (inputline = getline ()) { ! register int nbyte = strlen (inputline); /* * Write to master pty --- 300,312 ----- perror ("open"); while (inputline = getline ()) { ! /* ! * XXX: nbyte should be greater than 0 only for ^@ input in emacs. ! * This solution is very ugly.. but it will takes a half day ! * to fix this problem in more right way. I will fix this problem ! * in future release. ! */ ! register int nbyte = max (strlen (inputline), 1); /* * Write to master pty *** /tmp/,RCSt1012821 Fri Jan 6 08:51:34 1989 --- fep.1 Fri Nov 25 20:52:37 1988 *************** *** 1,5 .\" Copyright (c) 1987, 1988 by Software Research Associates, Inc. ! .\" $Header: fep.1,v 4.6 88/11/13 15:52:48 utashiro Exp $ .\"---------------------------------------- .TH FEP 1L "5 Aug 1988" "SRA Distribution" .SH NAME --- 1,5 ----- .\" Copyright (c) 1987, 1988 by Software Research Associates, Inc. ! .\" $Header: fep.1,v 4.7 88/11/25 20:51:20 utashiro Exp $ .\"---------------------------------------- .TH FEP 1L "5 Aug 1988" "SRA Distribution" .SH NAME *************** *** 70,75 esc-_ invoke-shell esc-< search-reverse esc-> search-forward .if t .sp .3v /* Bindings inherited from the tty driver */ .if t .sp .3v --- 70,78 ----- esc-_ invoke-shell esc-< search-reverse esc-> search-forward + esc-p insert-previous-history + esc-n insert-next-history + esc-. insert-current-history .if t .sp .3v /* Bindings inherited from the tty driver */ .if t .sp .3v *************** *** 524,529 new-line Insert newline next-history Get next history previous-history Get previous history repaint Repaint screen reprint Reprint line search-forward Search forward last !history --- 527,535 ----- new-line Insert newline next-history Get next history previous-history Get previous history + insert-next-history Insert next history + insert-previous-history Insert previous history + insert-current-history Insert current history repaint Repaint screen reprint Reprint line search-forward Search forward last !history