Changeset 10b866d
- Timestamp:
- Jul 8, 2002, 10:37:21 PM (23 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- e1c4636
- Parents:
- 8df36cc
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r8df36cc r10b866d 28 28 Always clear the command buffer before executing the command. 29 29 (So that interactive commands can sanely do start-command.) 30 30 Fixed preservation of e->dotsend across owl_editwin_clear(). 31 Added history for multiline edit windows (eg, for zephyr composition). 32 The M-n and M-p keys will cycle through the history ring. 33 In particular, it is now possible to edit the command line 34 of a zephyr being composed: C-c it and restart it 35 and then M-p to get the aborted composition back. 36 31 37 1.2.1-pre-1 32 38 Added RCS Id strings to all files. -
commands.c
r8df36cc r10b866d 593 593 594 594 OWLCMD_VOID_CTX("edit:history-next", owl_command_edit_history_next, 595 OWL_CTX_EDIT LINE,595 OWL_CTX_EDIT, 596 596 "replaces the text with the previous history", 597 597 "", ""), 598 598 599 599 OWLCMD_VOID_CTX("edit:history-prev", owl_command_edit_history_prev, 600 OWL_CTX_EDIT LINE,600 OWL_CTX_EDIT, 601 601 "replaces the text with the previous history", 602 602 "", ""), … … 1478 1478 1479 1479 void owl_command_edit_cancel(owl_editwin *e) { 1480 owl_history *hist; 1481 1480 1482 owl_function_makemsg("Command cancelled."); 1483 1484 hist=owl_editwin_get_history(e); 1485 owl_history_store(hist, owl_editwin_get_text(e)); 1486 owl_history_reset(hist); 1487 1481 1488 owl_editwin_fullclear(e); 1482 1489 owl_global_set_needrefresh(&g); 1483 1490 wnoutrefresh(owl_editwin_get_curswin(e)); 1484 1491 owl_global_set_typwin_inactive(&g); 1485 owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE );1492 owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE, NULL); 1486 1493 } 1487 1494 … … 1490 1497 char *ptr; 1491 1498 1492 hist=owl_ global_get_history(&g);1499 hist=owl_editwin_get_history(e); 1493 1500 if (!owl_history_is_touched(hist)) { 1494 1501 owl_history_store(hist, owl_editwin_get_text(e)); … … 1510 1517 char *ptr; 1511 1518 1512 hist=owl_ global_get_history(&g);1519 hist=owl_editwin_get_history(e); 1513 1520 ptr=owl_history_get_next(hist); 1514 1521 if (ptr) { … … 1531 1538 1532 1539 void owl_command_editline_done(owl_editwin *e) { 1533 owl_history *hist=owl_ global_get_history(&g);1540 owl_history *hist=owl_editwin_get_history(e); 1534 1541 char *rv, *cmd; 1535 1542 1536 owl_global_set_typwin_inactive(&g);1537 1543 owl_history_store(hist, owl_editwin_get_text(e)); 1538 1544 owl_history_reset(hist); 1545 owl_global_set_typwin_inactive(&g); 1539 1546 cmd = owl_strdup(owl_editwin_get_text(e)); 1540 1547 owl_editwin_fullclear(e); … … 1552 1559 1553 1560 void owl_command_editmulti_done(owl_editwin *e) { 1561 owl_history *hist=owl_editwin_get_history(e); 1562 1563 owl_history_store(hist, owl_editwin_get_text(e)); 1564 owl_history_reset(hist); 1565 1554 1566 owl_function_run_buffercommand(); 1555 owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE );1567 owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE, NULL); 1556 1568 owl_editwin_fullclear(e); 1557 1569 owl_global_set_typwin_inactive(&g); -
context.c
r1aee7d9 r10b866d 16 16 /* returns whether test matches the current context */ 17 17 int owl_context_matches(owl_context *ctx, int test) { 18 owl_function_debugmsg(", current: 0x%04x test: 0x%04x\n", ctx->mode, test);18 /*owl_function_debugmsg(", current: 0x%04x test: 0x%04x\n", ctx->mode, test);*/ 19 19 if ((((ctx->mode&OWL_CTX_MODE_BITS) & test) 20 20 || !(test&OWL_CTX_MODE_BITS)) -
editwin.c
r217a43e r10b866d 3 3 #include <unistd.h> 4 4 #include <string.h> 5 #include <ctype.h> 5 6 6 7 static const char fileIdent[] = "$Id$"; … … 8 9 #define INCR 5000 9 10 10 void owl_editwin_init(owl_editwin *e, WINDOW *win, int winlines, int wincols, int style ) {11 void owl_editwin_init(owl_editwin *e, WINDOW *win, int winlines, int wincols, int style, owl_history *hist) { 11 12 /* initialize the editwin e. 12 13 * 'win' is an already initialzed curses window that will be used by editwin 13 14 */ 14 e->buff=owl_malloc(INCR); 15 e->buff=owl_malloc(INCR); 15 16 e->buff[0]='\0'; 16 17 e->bufflen=0; 18 e->hist=hist; 17 19 e->allocated=INCR; 18 20 e->buffx=0; … … 50 52 } 51 53 54 void owl_editwin_set_history(owl_editwin *e, owl_history *h) { 55 e->hist = h; 56 } 57 58 owl_history *owl_editwin_get_history(owl_editwin *e) { 59 return e->hist; 60 } 61 52 62 void owl_editwin_set_dotsend(owl_editwin *e) { 53 63 e->dotsend=1; … … 85 95 } 86 96 87 void owl_editwin_new_style(owl_editwin *e, int newstyle ) {97 void owl_editwin_new_style(owl_editwin *e, int newstyle, owl_history *h) { 88 98 char *ptr; 89 99 100 owl_editwin_set_history(e, h); 90 101 if (e->style==newstyle) return; 91 102 … … 111 122 /* completly reinitialize the buffer */ 112 123 owl_free(e->buff); 113 owl_editwin_init(e, e->curswin, e->winlines, e->wincols, e->style );124 owl_editwin_init(e, e->curswin, e->winlines, e->wincols, e->style, e->hist); 114 125 } 115 126 … … 117 128 /* clear all text except for locktext and put the cursor at the beginning */ 118 129 int lock; 130 int dotsend=e->dotsend; 119 131 char *locktext=NULL; 120 132 121 133 lock=0; 122 134 if (e->lock > 0) { … … 129 141 130 142 owl_free(e->buff); 131 owl_editwin_init(e, e->curswin, e->winlines, e->wincols, e->style );143 owl_editwin_init(e, e->curswin, e->winlines, e->wincols, e->style, e->hist); 132 144 133 145 if (lock > 0) { 134 146 owl_editwin_set_locktext(e, locktext); 147 } 148 if (dotsend) { 149 owl_editwin_set_dotsend(e); 135 150 } 136 151 … … 742 757 /* returns if only whitespace remains */ 743 758 int owl_editwin_is_at_end(owl_editwin *e) { 744 int i, cur; 745 cur=_owl_editwin_get_index_from_xy(e); 746 if (cur >= e->bufflen) return(1); 747 for (i=e->bufflen-1; i>cur; i--) { 748 if (e->buff[i] != '\r' 749 && e->buff[i] != '\n' 750 && e->buff[i] != ' ') { 751 return(0); 752 } 753 } 754 if (cur==i) return(1); 755 else return(0); 759 int cur=_owl_editwin_get_index_from_xy(e); 760 return only_whitespace(e->buff+cur); 756 761 } 757 762 … … 768 773 return(1); 769 774 } 770 if (e->buff[i] != '\r' 771 && e->buff[i] != '\n' 772 && e->buff[i] != ' ') { 775 if (!isspace(e->buff[i])) { 773 776 return(0); 774 777 } -
functions.c
r217a43e r10b866d 124 124 /* create and setup the editwin */ 125 125 e=owl_global_get_typwin(&g); 126 owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE); 126 owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE, 127 owl_global_get_msg_history(&g)); 127 128 128 129 if (!owl_global_get_lockout_ctrld(&g)) { … … 1416 1417 1417 1418 if (enter) { 1418 owl_history_store(owl_global_get_history(&g), buff); 1419 owl_function_zwrite_setup(buff); 1420 owl_global_set_buffercommand(&g, buff); 1419 owl_history *hist = owl_global_get_cmd_history(&g); 1420 owl_history_store(hist, buff); 1421 owl_history_reset(hist); 1422 owl_function_command_norv(buff); 1421 1423 } else { 1422 1424 owl_function_start_command(buff); … … 1447 1449 tw=owl_global_get_typwin(&g); 1448 1450 owl_global_set_typwin_active(&g); 1451 owl_editwin_new_style(tw, OWL_EDITWIN_STYLE_ONELINE, 1452 owl_global_get_cmd_history(&g)); 1453 1449 1454 owl_editwin_set_locktext(tw, "command: "); 1450 1455 owl_global_set_needrefresh(&g); -
global.c
r1aee7d9 r10b866d 42 42 g->rightshift=0; 43 43 44 owl_editwin_init(&(g->tw), NULL, owl_global_get_typwin_lines(g), g->cols, OWL_EDITWIN_STYLE_ONELINE );44 owl_editwin_init(&(g->tw), NULL, owl_global_get_typwin_lines(g), g->cols, OWL_EDITWIN_STYLE_ONELINE, NULL); 45 45 46 46 owl_keyhandler_init(&g->kh); … … 65 65 owl_global_set_userclue(g, OWL_USERCLUE_NONE); 66 66 owl_global_set_no_have_config(g); 67 owl_history_init(&(g->hist)); 67 owl_history_init(&(g->msghist)); 68 owl_history_init(&(g->cmdhist)); 68 69 g->nextmsgid=0; 69 70 … … 486 487 /* history */ 487 488 488 owl_history *owl_global_get_history(owl_global *g) { 489 return(&(g->hist)); 489 owl_history *owl_global_get_msg_history(owl_global *g) { 490 return(&(g->msghist)); 491 } 492 493 owl_history *owl_global_get_cmd_history(owl_global *g) { 494 return(&(g->cmdhist)); 490 495 } 491 496 -
history.c
r1aee7d9 r10b866d 5 5 void owl_history_init(owl_history *h) { 6 6 owl_list_create(&(h->hist)); 7 h->cur=0; 8 h->touched=0; 9 h->partial=0; 7 h->cur=0; /* current position in history */ 8 h->touched=0; /* whether we've gone into history */ 9 h->partial=0; /* is the 0th element is partially composed? */ 10 10 } 11 11 12 12 char *owl_history_get_prev(owl_history *h) { 13 14 if (!h) return NULL; 13 15 h->touched=1; 14 16 … … 20 22 21 23 h->cur++; 24 22 25 return(owl_list_get_element(&(h->hist), h->cur)); 23 26 } 24 27 25 28 char *owl_history_get_next(owl_history *h) { 29 if (!h) return NULL; 26 30 if (owl_list_get_size(&(h->hist))==0) return(NULL); 27 28 31 if (h->cur==0) { 29 32 return(NULL); … … 37 40 int size; 38 41 42 if (!h) return; 43 39 44 /* if partial is set, remove the first entry first */ 40 45 if (h->partial) { 41 46 owl_list_remove_element(&(h->hist), 0); 42 47 } 43 48 44 49 /* if we've reached the max history size, pop off the last element */ 45 50 size=owl_list_get_size(&(h->hist)); … … 54 59 55 60 void owl_history_set_partial(owl_history *h) { 61 if (!h) return; 56 62 h->partial=1; 57 63 } 58 64 59 65 void owl_history_reset(owl_history *h) { 66 if (!h) return; 60 67 h->cur=0; 61 68 h->touched=0; … … 64 71 65 72 int owl_history_is_touched(owl_history *h) { 73 if (!h) return(0); 66 74 if (h->touched) return(1); 67 75 return(0); -
keymap.c
r1aee7d9 r10b866d 201 201 } 202 202 203 owl_function_debugmsg("processkey: got key %d, active keymap %s, stack at %d", 204 j, kh->active->name, kh->kpstackpos); 203 /* 204 owl_function_debugmsg("processkey: got key %d, active keymap %s, stack at %d", 205 j, kh->active->name, kh->kpstackpos); 206 */ 205 207 206 208 /* deal with ESC prefixing */ … … 236 238 match = owl_keybinding_match(kb, kh->kpstack); 237 239 if (match == 1) { /* subset match */ 238 owl_function_debugmsg("processkey: found subset match in %s", km->name); 240 241 /* owl_function_debugmsg("processkey: found subset match in %s", km->name); */ 239 242 return(0); 240 243 } else if (match == 2) { /* exact match */ 241 owl_function_debugmsg("processkey: found exact match in %s", km->name);244 /* owl_function_debugmsg("processkey: found exact match in %s", km->name); */ 242 245 owl_keybinding_execute(kb, j); 243 246 owl_keyhandler_reset(kh); … … 252 255 /* see if a default action exists for the active keymap */ 253 256 if (kh->active->default_fn && kh->kpstackpos<1) { 254 owl_function_debugmsg("processkey: executing default_fn"); 257 /*owl_function_debugmsg("processkey: executing default_fn");*/ 258 255 259 kh->active->default_fn(j); 256 260 owl_keyhandler_reset(kh); -
keys.c
r217a43e r10b866d 93 93 /* This would be nice, but interferes with C-c to cancel */ 94 94 /*BIND_CMD("C-c C-c", "editmulti:done", "sends the zephyr");*/ 95 96 BIND_CMD("M-p", "edit:history-prev", ""); 97 BIND_CMD("M-n", "edit:history-next", ""); 95 98 96 99 /* note that changing "disable-ctrl-d" to "on" will change this to -
owl.h
r1c7a4e0 r10b866d 238 238 } owl_mainwin; 239 239 240 typedef struct _owl_editwin {241 char *buff;242 int bufflen;243 int allocated;244 int buffx, buffy;245 int topline;246 int winlines, wincols, fillcol, wrapcol;247 WINDOW *curswin;248 int style;249 int lock;250 int dotsend;251 } owl_editwin;252 253 240 typedef struct _owl_viewwin { 254 241 owl_fmtext fmtext; … … 305 292 } owl_history; 306 293 294 typedef struct _owl_editwin { 295 char *buff; 296 owl_history *hist; 297 int bufflen; 298 int allocated; 299 int buffx, buffy; 300 int topline; 301 int winlines, wincols, fillcol, wrapcol; 302 WINDOW *curswin; 303 int style; 304 int lock; 305 int dotsend; 306 } owl_editwin; 307 307 308 typedef struct _owl_keybinding { 308 309 int *j; /* keypress stack (0-terminated) */ … … 334 335 owl_mainwin mw; 335 336 owl_popwin pw; 336 owl_history hist; 337 owl_history cmdhist; /* command history */ 338 owl_history msghist; /* outgoing message history */ 337 339 owl_keyhandler kh; 338 340 owl_list filterlist; -
util.c
r1c6c4d3 r10b866d 299 299 } 300 300 301 /* returns if a string is only whitespace */ 302 int only_whitespace(char *s) { 303 int i; 304 for (i=0; s[i]; i++) { 305 if (!isspace(s[i])) return(0); 306 } 307 return(1); 308 } 301 309 302 310 void *owl_malloc(size_t size) {
Note: See TracChangeset
for help on using the changeset viewer.