Changeset bab52da
- Timestamp:
- Jul 11, 2009, 1:14:34 PM (15 years ago)
- Branches:
- master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 98f1e69
- Parents:
- 521bc84
- git-author:
- Karl Ramm <kcr@1ts.org> (06/09/09 21:43:47)
- git-committer:
- Nelson Elhage <nelhage@mit.edu> (07/11/09 13:14:34)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
editwin.c
r521bc84 rbab52da 33 33 } oe_excursion; 34 34 35 static void oe_reframe(owl_editwin *e); 36 static void oe_save_excursion(owl_editwin *e, oe_excursion *x); 37 static void oe_restore_excursion(owl_editwin *e, oe_excursion *x); 38 static int oe_find_display_line(owl_editwin *e, int *x, int index); 39 static int owl_editwin_limit_maxcols(int v, int maxv); 40 static int owl_editwin_check_dotsend(owl_editwin *e); 41 static void _owl_editwin_process_char(owl_editwin *e, gunichar j); 35 42 static int owl_editwin_is_char_in(owl_editwin *e, char *set); 36 static void oe_reframe(owl_editwin *e); 43 static int owl_editwin_is_char_in(owl_editwin *e, char *set); 44 static int owl_editwin_linewrap_word(owl_editwin *e); 45 static gunichar owl_editwin_get_char_at_point(owl_editwin *e); 46 47 static void _owl_editwin_addspace(owl_editwin *e); 48 static void owl_editwin_overwrite_char(owl_editwin *e, gunichar c); 49 static void owl_editwin_insert_char(owl_editwin *e, gunichar c); 50 static void owl_editwin_overwrite_string(owl_editwin *e, char *string); 37 51 38 52 #define INCR 5000 … … 40 54 #define WHITESPACE " \n\t" 41 55 42 owl_editwin *owl_editwin_allocate(void) { 56 owl_editwin *owl_editwin_allocate(void) 57 { 43 58 return owl_malloc(sizeof(owl_editwin)); 44 59 } 45 60 46 static void oe_set_index(owl_editwin *e, int index) { 61 static inline void oe_set_index(owl_editwin *e, int index) 62 { 47 63 e->index = index; 48 64 e->goal_column = -1; … … 124 140 } 125 141 126 void owl_editwin_set_command(owl_editwin *e, char *command) { 142 void owl_editwin_set_command(owl_editwin *e, char *command) 143 { 127 144 if(e->command) owl_free(e->command); 128 145 e->command = owl_strdup(command); 129 146 } 130 147 131 char *owl_editwin_get_command(owl_editwin *e) { 148 char *owl_editwin_get_command(owl_editwin *e) 149 { 132 150 if(e->command) return e->command; 133 151 return ""; 134 152 } 135 153 136 void owl_editwin_set_callback(owl_editwin *e, void (*cb)(owl_editwin*)) { 154 void owl_editwin_set_callback(owl_editwin *e, void (*cb)(owl_editwin*)) 155 { 137 156 e->callback = cb; 138 157 } 139 158 140 void (*owl_editwin_get_callback(owl_editwin *e))(owl_editwin*) { 159 void (*owl_editwin_get_callback(owl_editwin *e))(owl_editwin*) 160 { 141 161 return e->callback; 142 162 } 143 163 144 void owl_editwin_set_cbdata(owl_editwin *e, void *data) { 164 void owl_editwin_set_cbdata(owl_editwin *e, void *data) 165 { 145 166 e->cbdata = data; 146 167 } … … 161 182 } 162 183 163 int owl_editwin_limit_maxcols(int v, int maxv)184 static int owl_editwin_limit_maxcols(int v, int maxv) 164 185 { 165 186 if (maxv > 5 && v > maxv) { … … 255 276 256 277 /* malloc more space for the buffer */ 257 void _owl_editwin_addspace(owl_editwin *e)278 static void _owl_editwin_addspace(owl_editwin *e) 258 279 { 259 280 e->buff=owl_realloc(e->buff, e->allocated+INCR); … … 469 490 * returns -1 if we could not wrap. 470 491 */ 471 int _owl_editwin_linewrap_word(owl_editwin *e)492 static int owl_editwin_linewrap_word(owl_editwin *e) 472 493 { 473 494 int i; … … 504 525 * characters over) 505 526 */ 506 void owl_editwin_insert_char(owl_editwin *e, gunichar c)527 static void owl_editwin_insert_char(owl_editwin *e, gunichar c) 507 528 { 508 529 int i, ret, len; … … 553 574 554 575 /* overwrite the character at the current point with 'c' */ 555 void owl_editwin_overwrite_char(owl_editwin *e, gunichar c)576 static void owl_editwin_overwrite_char(owl_editwin *e, gunichar c) 556 577 { 557 578 int oldlen, newlen, i; … … 692 713 */ 693 714 694 void owl_editwin_overwrite_string(owl_editwin *e, char *string)715 static void owl_editwin_overwrite_string(owl_editwin *e, char *string) 695 716 { 696 717 char *p; … … 711 732 712 733 /* We assume index is not set to point to a mid-char */ 713 gunichar _owl_editwin_get_char_at_point(owl_editwin *e)734 static gunichar owl_editwin_get_char_at_point(owl_editwin *e) 714 735 { 715 736 return g_utf8_get_char(e->buff + e->index); … … 762 783 oe_save_excursion(e, &x); 763 784 owl_editwin_point_move(e, -1); 764 ret = ( _owl_editwin_get_char_at_point(e) == '\n');785 ret = (owl_editwin_get_char_at_point(e) == '\n'); 765 786 oe_restore_excursion(e, &x); 766 787 … … 773 794 /* It would be awfully nice if we could do UTF-8 comparisons */ 774 795 for (p = set; *p != 0; p++) 775 if ( _owl_editwin_get_char_at_point(e) == *p)796 if (owl_editwin_get_char_at_point(e) == *p) 776 797 return 1; 777 798 return 0; … … 1072 1093 } 1073 1094 1074 int owl_editwin_check_dotsend(owl_editwin *e)1095 static int owl_editwin_check_dotsend(owl_editwin *e) 1075 1096 { 1076 1097 char *p, *p_n, *p_p; … … 1110 1131 } 1111 1132 1112 void _owl_editwin_process_char(owl_editwin *e, gunichar j)1133 static void _owl_editwin_process_char(owl_editwin *e, gunichar j) 1113 1134 { 1114 1135 if (!(g_unichar_iscntrl(j) && (j != 10) && (j != 13)) || j==9 ) {
Note: See TracChangeset
for help on using the changeset viewer.