- Timestamp:
- Jul 8, 2002, 10:37:21 PM (21 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- e1c4636
- Parents:
- 8df36cc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.