[7d4fbcd] | 1 | #include "owl.h" |
---|
| 2 | #include <stdlib.h> |
---|
| 3 | #include <unistd.h> |
---|
| 4 | #include <string.h> |
---|
[10b866d] | 5 | #include <ctype.h> |
---|
[7d4fbcd] | 6 | |
---|
[1aee7d9] | 7 | static const char fileIdent[] = "$Id$"; |
---|
| 8 | |
---|
[ebf0128] | 9 | #define VALID_EXCURSION (0x9a2b4729) |
---|
| 10 | |
---|
[a88f35a] | 11 | typedef struct _owl_editwin_excursion { /*noproto*/ |
---|
[ebf0128] | 12 | int valid; |
---|
| 13 | int index; |
---|
[16cfd12a] | 14 | int mark; |
---|
[ebf0128] | 15 | int goal_column; |
---|
| 16 | int lock; |
---|
[a88f35a] | 17 | struct _owl_editwin_excursion *next; |
---|
[ebf0128] | 18 | } oe_excursion; |
---|
| 19 | |
---|
[a556caa] | 20 | struct _owl_editwin { /*noproto*/ |
---|
| 21 | char *buff; |
---|
| 22 | owl_history *hist; |
---|
| 23 | int bufflen; |
---|
| 24 | int allocated; |
---|
| 25 | int index; |
---|
[16cfd12a] | 26 | int mark; |
---|
[a60edf2] | 27 | char *killbuf; |
---|
[a556caa] | 28 | int goal_column; |
---|
| 29 | int topindex; |
---|
[ebf0128] | 30 | int cursorx; |
---|
[a556caa] | 31 | int winlines, wincols, fillcol, wrapcol; |
---|
| 32 | WINDOW *curswin; |
---|
| 33 | int style; |
---|
| 34 | int lock; |
---|
| 35 | int dotsend; |
---|
| 36 | int echochar; |
---|
[ebf0128] | 37 | oe_excursion *excursions; |
---|
[a556caa] | 38 | |
---|
| 39 | char *command; |
---|
| 40 | void (*callback)(struct _owl_editwin*); |
---|
| 41 | void *cbdata; |
---|
| 42 | }; |
---|
| 43 | |
---|
[e20d8179] | 44 | static void oe_reframe(owl_editwin *e); |
---|
[bab52da] | 45 | static void oe_save_excursion(owl_editwin *e, oe_excursion *x); |
---|
[ebf0128] | 46 | static void oe_release_excursion(owl_editwin *e, oe_excursion *x); |
---|
[bab52da] | 47 | static void oe_restore_excursion(owl_editwin *e, oe_excursion *x); |
---|
[a60edf2] | 48 | static void oe_restore_mark_only(owl_editwin *e, oe_excursion *x); |
---|
[ebf0128] | 49 | static int oe_count_glyphs(char *s); |
---|
| 50 | static int oe_char_width(gunichar c, int column); |
---|
[16cfd12a] | 51 | static int oe_region_width(owl_editwin *e, int start, int end, int width); |
---|
[bab52da] | 52 | static int oe_find_display_line(owl_editwin *e, int *x, int index); |
---|
[ebf0128] | 53 | static void oe_insert_char(owl_editwin *e, gunichar c); |
---|
[bab52da] | 54 | static int owl_editwin_limit_maxcols(int v, int maxv); |
---|
| 55 | static int owl_editwin_check_dotsend(owl_editwin *e); |
---|
| 56 | static int owl_editwin_is_char_in(owl_editwin *e, char *set); |
---|
| 57 | static gunichar owl_editwin_get_char_at_point(owl_editwin *e); |
---|
[19a023f] | 58 | static int owl_editwin_replace_internal(owl_editwin *e, int replace, char *s); |
---|
[a60edf2] | 59 | static char *oe_copy_buf(owl_editwin *e, char *buf, int len); |
---|
| 60 | static int oe_copy_region(owl_editwin *e); |
---|
[fc2677b] | 61 | static int oe_display_column(owl_editwin *e); |
---|
[77f605d] | 62 | static char *oe_chunk(owl_editwin *e, int start, int end); |
---|
[bab52da] | 63 | |
---|
[5b5f3e6] | 64 | #define INCR 4096 |
---|
[7d4fbcd] | 65 | |
---|
[a556caa] | 66 | #define WHITESPACE " \n\t" |
---|
| 67 | |
---|
[bab52da] | 68 | owl_editwin *owl_editwin_allocate(void) |
---|
| 69 | { |
---|
[8321cb7] | 70 | owl_editwin *e; |
---|
| 71 | e = owl_malloc(sizeof(owl_editwin)); |
---|
| 72 | memset(e, 0, sizeof(*e)); |
---|
| 73 | return e; |
---|
[a556caa] | 74 | } |
---|
| 75 | |
---|
[5b5f3e6] | 76 | static int oe_count_glyphs(char *s) |
---|
| 77 | { |
---|
| 78 | int count = 0; |
---|
| 79 | char *p; |
---|
| 80 | |
---|
| 81 | for(p = s; *p != 0; p = g_utf8_find_next_char(p, NULL)) |
---|
| 82 | if (!g_unichar_ismark(g_utf8_get_char(p))) |
---|
| 83 | count++; |
---|
| 84 | |
---|
| 85 | return count; |
---|
| 86 | } |
---|
| 87 | |
---|
[bab52da] | 88 | static inline void oe_set_index(owl_editwin *e, int index) |
---|
| 89 | { |
---|
[ebf0128] | 90 | if (index != e->index) { |
---|
| 91 | e->goal_column = -1; |
---|
| 92 | e->cursorx = -1; |
---|
| 93 | } |
---|
[521bc84] | 94 | e->index = index; |
---|
| 95 | } |
---|
| 96 | |
---|
[7f0c26f] | 97 | static inline void oe_set_mark(owl_editwin *e, int mark) |
---|
| 98 | { |
---|
| 99 | e->mark = mark; |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | void owl_editwin_set_mark(owl_editwin *e) |
---|
| 103 | { |
---|
| 104 | oe_set_mark(e, e->index); |
---|
| 105 | /* owl_function_makemsg("Mark set."); */ |
---|
| 106 | } |
---|
| 107 | |
---|
[cf83b7a] | 108 | /* initialize the editwin e. |
---|
| 109 | * 'win' is an already initialzed curses window that will be used by editwin |
---|
| 110 | */ |
---|
[c9334b1] | 111 | void owl_editwin_init(owl_editwin *e, WINDOW *win, int winlines, int wincols, int style, owl_history *hist) |
---|
| 112 | { |
---|
[e20d8179] | 113 | e->buff=owl_malloc(INCR); |
---|
[7d4fbcd] | 114 | e->buff[0]='\0'; |
---|
| 115 | e->bufflen=0; |
---|
[10b866d] | 116 | e->hist=hist; |
---|
[7d4fbcd] | 117 | e->allocated=INCR; |
---|
[521bc84] | 118 | oe_set_index(e, 0); |
---|
[7f0c26f] | 119 | oe_set_mark(e, -1); |
---|
[a60edf2] | 120 | if (e->killbuf != NULL) |
---|
| 121 | free(e->killbuf); |
---|
| 122 | e->killbuf = NULL; |
---|
[a556caa] | 123 | e->goal_column = -1; |
---|
[ebf0128] | 124 | e->cursorx = -1; |
---|
| 125 | e->topindex = 0; |
---|
| 126 | e->excursions = NULL; |
---|
| 127 | owl_editwin_set_curswin(e, win, winlines, wincols); |
---|
[7d4fbcd] | 128 | e->style=style; |
---|
| 129 | if ((style!=OWL_EDITWIN_STYLE_MULTILINE) && |
---|
| 130 | (style!=OWL_EDITWIN_STYLE_ONELINE)) { |
---|
| 131 | e->style=OWL_EDITWIN_STYLE_MULTILINE; |
---|
| 132 | } |
---|
| 133 | e->lock=0; |
---|
| 134 | e->dotsend=0; |
---|
[c9334b1] | 135 | e->echochar='\0'; |
---|
[e74c01c] | 136 | |
---|
[af1920fd] | 137 | /* We get initialized multiple times, but we need to hold on to |
---|
| 138 | the callbacks, so we can't NULL them here. */ |
---|
[e74c01c] | 139 | /* |
---|
| 140 | e->command = NULL; |
---|
| 141 | e->callback = NULL; |
---|
| 142 | e->cbdata = NULL; |
---|
| 143 | */ |
---|
[7d4fbcd] | 144 | if (win) werase(win); |
---|
| 145 | } |
---|
| 146 | |
---|
[c9334b1] | 147 | void owl_editwin_set_curswin(owl_editwin *e, WINDOW *w, int winlines, int wincols) |
---|
| 148 | { |
---|
[7d4fbcd] | 149 | e->curswin=w; |
---|
| 150 | e->winlines=winlines; |
---|
| 151 | e->wincols=wincols; |
---|
[9a6cc40] | 152 | e->fillcol=owl_editwin_limit_maxcols(wincols-7, owl_global_get_edit_maxfillcols(&g)); |
---|
| 153 | e->wrapcol=owl_editwin_limit_maxcols(wincols-7, owl_global_get_edit_maxwrapcols(&g)); |
---|
[7d4fbcd] | 154 | } |
---|
| 155 | |
---|
[c9334b1] | 156 | /* echo the character 'ch' for each normal character keystroke, |
---|
| 157 | * excepting locktext. This is useful for entering passwords etc. If |
---|
| 158 | * ch=='\0' characters are echo'd normally |
---|
| 159 | */ |
---|
| 160 | void owl_editwin_set_echochar(owl_editwin *e, int ch) |
---|
| 161 | { |
---|
| 162 | e->echochar=ch; |
---|
| 163 | } |
---|
| 164 | |
---|
| 165 | WINDOW *owl_editwin_get_curswin(owl_editwin *e) |
---|
| 166 | { |
---|
[060b3b4] | 167 | return(e->curswin); |
---|
[7d4fbcd] | 168 | } |
---|
| 169 | |
---|
[c9334b1] | 170 | owl_history *owl_editwin_get_history(owl_editwin *e) |
---|
| 171 | { |
---|
[060b3b4] | 172 | return(e->hist); |
---|
[10b866d] | 173 | } |
---|
| 174 | |
---|
[c9334b1] | 175 | void owl_editwin_set_dotsend(owl_editwin *e) |
---|
| 176 | { |
---|
[7d4fbcd] | 177 | e->dotsend=1; |
---|
| 178 | } |
---|
| 179 | |
---|
[bab52da] | 180 | void owl_editwin_set_command(owl_editwin *e, char *command) |
---|
| 181 | { |
---|
[e74c01c] | 182 | if(e->command) owl_free(e->command); |
---|
| 183 | e->command = owl_strdup(command); |
---|
| 184 | } |
---|
| 185 | |
---|
[bab52da] | 186 | char *owl_editwin_get_command(owl_editwin *e) |
---|
| 187 | { |
---|
[e74c01c] | 188 | if(e->command) return e->command; |
---|
| 189 | return ""; |
---|
| 190 | } |
---|
| 191 | |
---|
[bab52da] | 192 | void owl_editwin_set_callback(owl_editwin *e, void (*cb)(owl_editwin*)) |
---|
| 193 | { |
---|
[e74c01c] | 194 | e->callback = cb; |
---|
| 195 | } |
---|
| 196 | |
---|
[bab52da] | 197 | void (*owl_editwin_get_callback(owl_editwin *e))(owl_editwin*) |
---|
| 198 | { |
---|
[e74c01c] | 199 | return e->callback; |
---|
| 200 | } |
---|
| 201 | |
---|
[bab52da] | 202 | void owl_editwin_set_cbdata(owl_editwin *e, void *data) |
---|
| 203 | { |
---|
[e74c01c] | 204 | e->cbdata = data; |
---|
| 205 | } |
---|
| 206 | |
---|
[a556caa] | 207 | void *owl_editwin_get_cbdata(owl_editwin *e) { |
---|
[e74c01c] | 208 | return e->cbdata; |
---|
| 209 | } |
---|
| 210 | |
---|
| 211 | void owl_editwin_do_callback(owl_editwin *e) { |
---|
| 212 | void (*cb)(owl_editwin*); |
---|
| 213 | cb=owl_editwin_get_callback(e); |
---|
| 214 | if(!cb) { |
---|
| 215 | owl_function_error("Internal error: No editwin callback!"); |
---|
| 216 | } else { |
---|
[af1920fd] | 217 | /* owl_function_error("text: |%s|", owl_editwin_get_text(e)); */ |
---|
[e74c01c] | 218 | cb(e); |
---|
| 219 | } |
---|
| 220 | } |
---|
| 221 | |
---|
[bab52da] | 222 | static int owl_editwin_limit_maxcols(int v, int maxv) |
---|
[c9334b1] | 223 | { |
---|
[ebf0128] | 224 | /* maxv > 5 ? MAX(v, vax) : v */ |
---|
[d36f2cb] | 225 | if (maxv > 5 && v > maxv) { |
---|
[060b3b4] | 226 | return(maxv); |
---|
[d36f2cb] | 227 | } else { |
---|
[060b3b4] | 228 | return(v); |
---|
[d36f2cb] | 229 | } |
---|
| 230 | } |
---|
| 231 | |
---|
[c9334b1] | 232 | /* set text to be 'locked in' at the beginning of the buffer, any |
---|
| 233 | * previous text (including locked text) will be overwritten |
---|
| 234 | */ |
---|
| 235 | void owl_editwin_set_locktext(owl_editwin *e, char *text) |
---|
| 236 | { |
---|
[521bc84] | 237 | oe_set_index(e, 0); |
---|
[5b5f3e6] | 238 | e->lock = 0; |
---|
| 239 | owl_editwin_replace(e, e->bufflen, text); |
---|
| 240 | e->buff[e->bufflen] = 0; |
---|
| 241 | e->lock=e->bufflen; |
---|
[521bc84] | 242 | oe_set_index(e, e->lock); |
---|
[7d4fbcd] | 243 | owl_editwin_redisplay(e, 0); |
---|
| 244 | } |
---|
| 245 | |
---|
[c9334b1] | 246 | int owl_editwin_get_style(owl_editwin *e) |
---|
| 247 | { |
---|
[7d4fbcd] | 248 | return(e->style); |
---|
| 249 | } |
---|
| 250 | |
---|
[c9334b1] | 251 | void owl_editwin_new_style(owl_editwin *e, int newstyle, owl_history *h) |
---|
| 252 | { |
---|
[98f1e69] | 253 | e->hist = h; |
---|
| 254 | |
---|
[7d4fbcd] | 255 | if (e->style==newstyle) return; |
---|
| 256 | |
---|
| 257 | if (newstyle==OWL_EDITWIN_STYLE_MULTILINE) { |
---|
| 258 | e->style=newstyle; |
---|
| 259 | } else if (newstyle==OWL_EDITWIN_STYLE_ONELINE) { |
---|
| 260 | e->style=newstyle; |
---|
| 261 | |
---|
| 262 | /* nuke everything after the first line */ |
---|
[5b5f3e6] | 263 | owl_editwin_move_to_top(e); |
---|
| 264 | owl_editwin_move_to_end_of_line(e); |
---|
| 265 | owl_editwin_replace(e, oe_count_glyphs(e->buff + e->index), ""); |
---|
[7d4fbcd] | 266 | } |
---|
| 267 | } |
---|
| 268 | |
---|
[c9334b1] | 269 | /* completly reinitialize the buffer */ |
---|
| 270 | void owl_editwin_fullclear(owl_editwin *e) |
---|
| 271 | { |
---|
[7d4fbcd] | 272 | owl_free(e->buff); |
---|
[10b866d] | 273 | owl_editwin_init(e, e->curswin, e->winlines, e->wincols, e->style, e->hist); |
---|
[7d4fbcd] | 274 | } |
---|
| 275 | |
---|
[c9334b1] | 276 | /* clear all text except for locktext and put the cursor at the |
---|
| 277 | * beginning |
---|
| 278 | */ |
---|
| 279 | void owl_editwin_clear(owl_editwin *e) |
---|
| 280 | { |
---|
| 281 | |
---|
[6073462] | 282 | int lock = e->lock; |
---|
[10b866d] | 283 | int dotsend=e->dotsend; |
---|
[7d4fbcd] | 284 | char *locktext=NULL; |
---|
[cc6f009] | 285 | char echochar=e->echochar; |
---|
[10b866d] | 286 | |
---|
[6073462] | 287 | if (lock > 0) { |
---|
[5b5f3e6] | 288 | locktext = owl_malloc(lock+1); |
---|
| 289 | strncpy(locktext, e->buff, lock); |
---|
| 290 | locktext[lock] = 0; |
---|
[7d4fbcd] | 291 | } |
---|
| 292 | |
---|
| 293 | owl_free(e->buff); |
---|
[10b866d] | 294 | owl_editwin_init(e, e->curswin, e->winlines, e->wincols, e->style, e->hist); |
---|
[7d4fbcd] | 295 | |
---|
| 296 | if (lock > 0) { |
---|
| 297 | owl_editwin_set_locktext(e, locktext); |
---|
| 298 | } |
---|
[10b866d] | 299 | if (dotsend) { |
---|
| 300 | owl_editwin_set_dotsend(e); |
---|
| 301 | } |
---|
[cc6f009] | 302 | if (echochar) { |
---|
| 303 | owl_editwin_set_echochar(e, echochar); |
---|
| 304 | } |
---|
[7d4fbcd] | 305 | |
---|
[5b5f3e6] | 306 | if (locktext) |
---|
| 307 | owl_free(locktext); |
---|
[6073462] | 308 | |
---|
[521bc84] | 309 | oe_set_index(e, lock); |
---|
[7d4fbcd] | 310 | } |
---|
| 311 | |
---|
[c9334b1] | 312 | void owl_editwin_recenter(owl_editwin *e) |
---|
| 313 | { |
---|
[a556caa] | 314 | e->topindex = -1; |
---|
| 315 | } |
---|
[e20d8179] | 316 | |
---|
[a0fbdee] | 317 | static void oe_save_excursion(owl_editwin *e, oe_excursion *x) |
---|
| 318 | { |
---|
| 319 | x->index = e->index; |
---|
[7f0c26f] | 320 | x->mark = e->mark; |
---|
[a0fbdee] | 321 | x->goal_column = e->goal_column; |
---|
| 322 | x->lock = e->lock; |
---|
[ebf0128] | 323 | |
---|
| 324 | x->valid = VALID_EXCURSION; |
---|
| 325 | x->next = e->excursions; |
---|
| 326 | e->excursions = x; |
---|
| 327 | } |
---|
| 328 | |
---|
| 329 | static void oe_release_excursion(owl_editwin *e, oe_excursion *x) |
---|
| 330 | { |
---|
| 331 | oe_excursion *p; |
---|
| 332 | |
---|
| 333 | x->valid = 0; |
---|
| 334 | if (e->excursions == NULL) |
---|
| 335 | /* XXX huh. */ ; |
---|
| 336 | else if (e->excursions == x) |
---|
| 337 | e->excursions = x->next; |
---|
| 338 | else { |
---|
| 339 | for (p = e->excursions; p->next != NULL; p = p->next) |
---|
| 340 | if (p->next == x) { |
---|
| 341 | p->next = p->next->next; |
---|
| 342 | break; |
---|
| 343 | } |
---|
| 344 | /* and if we ran off the end? XXX */ |
---|
| 345 | } |
---|
[a0fbdee] | 346 | } |
---|
| 347 | |
---|
| 348 | static void oe_restore_excursion(owl_editwin *e, oe_excursion *x) |
---|
| 349 | { |
---|
[ebf0128] | 350 | if (x->valid == VALID_EXCURSION) { |
---|
| 351 | oe_set_index(e, x->index); |
---|
| 352 | e->goal_column = x->goal_column; |
---|
[7f0c26f] | 353 | e->mark = x->mark; |
---|
[ebf0128] | 354 | e->lock = x->lock; |
---|
| 355 | |
---|
| 356 | oe_release_excursion(e, x); |
---|
| 357 | } |
---|
[a0fbdee] | 358 | } |
---|
| 359 | |
---|
[a60edf2] | 360 | static void oe_restore_mark_only(owl_editwin *e, oe_excursion *x) |
---|
| 361 | { |
---|
| 362 | if (x->valid == VALID_EXCURSION) { |
---|
| 363 | e->mark = x->mark; |
---|
| 364 | |
---|
| 365 | oe_release_excursion(e, x); |
---|
| 366 | } |
---|
| 367 | } |
---|
| 368 | |
---|
[a88f35a] | 369 | /* External interface to oe_save_excursion */ |
---|
| 370 | owl_editwin_excursion *owl_editwin_begin_excursion(owl_editwin *e) |
---|
| 371 | { |
---|
| 372 | owl_editwin_excursion *x = owl_malloc(sizeof *x); |
---|
| 373 | oe_save_excursion(e, x); |
---|
| 374 | return x; |
---|
| 375 | } |
---|
| 376 | |
---|
| 377 | void owl_editwin_end_excursion(owl_editwin *e, owl_editwin_excursion *x) |
---|
| 378 | { |
---|
| 379 | oe_restore_excursion(e, x); |
---|
| 380 | owl_free(x); |
---|
| 381 | } |
---|
| 382 | |
---|
[e20d8179] | 383 | static inline char *oe_next_point(owl_editwin *e, char *p) |
---|
| 384 | { |
---|
| 385 | char *boundary = e->buff + e->bufflen + 1; |
---|
| 386 | char *q; |
---|
| 387 | |
---|
| 388 | q = g_utf8_find_next_char(p, boundary); |
---|
| 389 | while (q && g_unichar_ismark(g_utf8_get_char(q))) |
---|
| 390 | q = g_utf8_find_next_char(q, boundary); |
---|
| 391 | |
---|
| 392 | if (q == p) |
---|
| 393 | return NULL; |
---|
| 394 | return q; |
---|
| 395 | } |
---|
| 396 | |
---|
| 397 | static inline char *oe_prev_point(owl_editwin *e, char *p) |
---|
| 398 | { |
---|
| 399 | char *boundary = e->buff + e->lock; |
---|
| 400 | |
---|
| 401 | p = g_utf8_find_prev_char(boundary, p); |
---|
| 402 | while (p && g_unichar_ismark(g_utf8_get_char(p))) |
---|
| 403 | p = g_utf8_find_prev_char(boundary, p); |
---|
| 404 | |
---|
| 405 | return p; |
---|
| 406 | } |
---|
| 407 | |
---|
[ebf0128] | 408 | static int oe_char_width(gunichar c, int column) |
---|
| 409 | { |
---|
| 410 | int cw; |
---|
| 411 | |
---|
| 412 | if (c == 9) /* TAB */ |
---|
| 413 | return TABSIZE - column % TABSIZE; |
---|
| 414 | |
---|
| 415 | cw = mk_wcwidth(c); |
---|
| 416 | |
---|
| 417 | if (cw < 0) /* control characters */ |
---|
| 418 | cw = 0; |
---|
| 419 | |
---|
| 420 | return cw; |
---|
| 421 | } |
---|
| 422 | |
---|
[19f765d] | 423 | static int oe_find_display_line(owl_editwin *e, int *x, int index) |
---|
| 424 | { |
---|
| 425 | int width = 0, cw; |
---|
[ebf0128] | 426 | gunichar c; |
---|
[19f765d] | 427 | char *p; |
---|
| 428 | |
---|
[77d4402] | 429 | while(1) { |
---|
| 430 | /* note the position of the dot */ |
---|
[2021bea] | 431 | if (x != NULL && index == e->index && width < e->wincols) |
---|
[19f765d] | 432 | *x = width; |
---|
[77d4402] | 433 | |
---|
[19f765d] | 434 | /* get the current character */ |
---|
| 435 | c = g_utf8_get_char(e->buff + index); |
---|
| 436 | |
---|
| 437 | /* figure out how wide it is */ |
---|
[ebf0128] | 438 | cw = oe_char_width(c, width); |
---|
[19f765d] | 439 | |
---|
[77d4402] | 440 | if (width + cw > e->wincols) { |
---|
| 441 | if (x != NULL && *x == width) |
---|
| 442 | *x = -1; |
---|
[19f765d] | 443 | break; |
---|
[77d4402] | 444 | } |
---|
[19f765d] | 445 | width += cw; |
---|
| 446 | |
---|
| 447 | if (c == '\n') { |
---|
[77d4402] | 448 | if (width < e->wincols) |
---|
| 449 | ++index; /* skip the newline */ |
---|
[19f765d] | 450 | break; |
---|
| 451 | } |
---|
| 452 | |
---|
| 453 | /* find the next character */ |
---|
| 454 | p = oe_next_point(e, e->buff + index); |
---|
| 455 | if (p == NULL) { /* we ran off the end */ |
---|
| 456 | if (x != NULL && e->index > index) |
---|
| 457 | *x = width + 1; |
---|
| 458 | break; |
---|
| 459 | } |
---|
| 460 | index = p - e->buff; |
---|
[cedc95c] | 461 | |
---|
[19f765d] | 462 | } |
---|
| 463 | return index; |
---|
| 464 | } |
---|
| 465 | |
---|
[e20d8179] | 466 | static void oe_reframe(owl_editwin *e) { |
---|
[cedc95c] | 467 | oe_excursion x; |
---|
| 468 | int goal = e->winlines / 2; |
---|
| 469 | int index; |
---|
| 470 | int count = 0; |
---|
| 471 | int point; |
---|
| 472 | int n, i; |
---|
| 473 | int last; |
---|
| 474 | |
---|
| 475 | oe_save_excursion(e, &x); |
---|
| 476 | /* step back line-by-line through the buffer until we have >= goal lines of |
---|
| 477 | display text */ |
---|
| 478 | e->lock = 0; /* we can (must) tread on the locktext */ |
---|
| 479 | |
---|
| 480 | point = e->index; |
---|
| 481 | last = -1; |
---|
| 482 | while (count < goal) { |
---|
| 483 | index = e->index; |
---|
| 484 | owl_editwin_move_to_beginning_of_line(e); |
---|
| 485 | if (last == e->index) |
---|
| 486 | break; |
---|
| 487 | last = e->index; |
---|
| 488 | for (n = 0, i = e->index; i < index; n++) |
---|
| 489 | i = oe_find_display_line(e, NULL, i); |
---|
| 490 | count += n == 0 ? 1 : n; |
---|
| 491 | if (count < goal) |
---|
| 492 | owl_editwin_point_move(e, -1); |
---|
| 493 | } |
---|
| 494 | |
---|
| 495 | e->topindex = e->index; |
---|
[521bc84] | 496 | /* if we overshot, backtrack */ |
---|
| 497 | for (n = 0; n < (count - goal); n++) |
---|
| 498 | e->topindex = oe_find_display_line(e, NULL, e->topindex); |
---|
[cedc95c] | 499 | |
---|
| 500 | oe_restore_excursion(e, &x); |
---|
[7d4fbcd] | 501 | } |
---|
| 502 | |
---|
[3e36085] | 503 | static void oe_addnec(owl_editwin *e, int count) |
---|
| 504 | { |
---|
| 505 | int i; |
---|
| 506 | |
---|
| 507 | for (i = 0; i < count; i++) |
---|
| 508 | waddch(e->curswin, e->echochar); |
---|
| 509 | } |
---|
| 510 | |
---|
| 511 | static void oe_mvaddnec(owl_editwin *e, int y, int x, int count) |
---|
| 512 | { |
---|
| 513 | wmove(e->curswin, y, x); |
---|
| 514 | oe_addnec(e, count); |
---|
| 515 | } |
---|
| 516 | |
---|
[c9334b1] | 517 | /* regenerate the text on the curses window */ |
---|
| 518 | /* if update == 1 then do a doupdate(), otherwise do not */ |
---|
| 519 | void owl_editwin_redisplay(owl_editwin *e, int update) |
---|
| 520 | { |
---|
[19f765d] | 521 | int x = -1, y = -1, t; |
---|
[77d4402] | 522 | int line, index, lineindex, times = 0; |
---|
[7d4fbcd] | 523 | |
---|
[bd1a1ae] | 524 | do { |
---|
[cedc95c] | 525 | werase(e->curswin); |
---|
| 526 | |
---|
[bd1a1ae] | 527 | if (e->topindex == -1 || e->index < e->topindex) |
---|
[e20d8179] | 528 | oe_reframe(e); |
---|
| 529 | |
---|
[bd1a1ae] | 530 | line = 0; |
---|
| 531 | index = e->topindex; |
---|
| 532 | while(line < e->winlines) { |
---|
| 533 | lineindex = index; |
---|
[19f765d] | 534 | t = -1; |
---|
| 535 | index = oe_find_display_line(e, &t, lineindex); |
---|
| 536 | if (x == -1 && t != -1) |
---|
| 537 | x = t, y = line; |
---|
[3e36085] | 538 | if (index - lineindex) { |
---|
| 539 | if (!e->echochar) |
---|
| 540 | mvwaddnstr(e->curswin, line, 0, |
---|
| 541 | e->buff + lineindex, |
---|
| 542 | index - lineindex); |
---|
| 543 | else { |
---|
| 544 | if(lineindex < e->lock) { |
---|
| 545 | mvwaddnstr(e->curswin, line, 0, |
---|
| 546 | e->buff + lineindex, |
---|
| 547 | MIN(index - lineindex, |
---|
| 548 | e->lock - lineindex)); |
---|
| 549 | if (e->lock < index) |
---|
| 550 | oe_addnec(e, |
---|
| 551 | oe_region_width(e, e->lock, index, |
---|
| 552 | oe_region_width(e, lineindex, e->lock, 0))); |
---|
| 553 | } else |
---|
| 554 | oe_mvaddnec(e, line, 0, oe_region_width(e, line, index, 0)); |
---|
| 555 | } |
---|
| 556 | } |
---|
[bd1a1ae] | 557 | line++; |
---|
[a556caa] | 558 | } |
---|
[19f765d] | 559 | if (x == -1) |
---|
[bd1a1ae] | 560 | e->topindex = -1; /* force a reframe */ |
---|
[77d4402] | 561 | times++; |
---|
| 562 | } while(x == -1 && times < 3); |
---|
[e20d8179] | 563 | |
---|
[19f765d] | 564 | wmove(e->curswin, y, x); |
---|
[ebf0128] | 565 | e->cursorx = x; |
---|
| 566 | |
---|
[7d4fbcd] | 567 | wnoutrefresh(e->curswin); |
---|
[a556caa] | 568 | if (update == 1) |
---|
[7d4fbcd] | 569 | doupdate(); |
---|
| 570 | } |
---|
| 571 | |
---|
[7f0c26f] | 572 | static inline void oe_fixup(int *target, int start, int end, int change) { |
---|
| 573 | if (*target > start) { |
---|
| 574 | if (*target < end) |
---|
| 575 | *target = end; |
---|
| 576 | else |
---|
| 577 | *target += change; |
---|
| 578 | } |
---|
| 579 | } |
---|
| 580 | |
---|
[a88f35a] | 581 | int owl_editwin_replace_region(owl_editwin *e, char *s) |
---|
| 582 | { |
---|
| 583 | oe_excursion x; |
---|
| 584 | oe_save_excursion(e, &x); |
---|
| 585 | int ret; |
---|
| 586 | |
---|
| 587 | if(e->index > e->mark) { |
---|
| 588 | owl_editwin_exchange_point_and_mark(e); |
---|
| 589 | } |
---|
| 590 | |
---|
| 591 | ret = owl_editwin_replace_internal(e, e->mark - e->index, s); |
---|
| 592 | |
---|
| 593 | oe_restore_excursion(e, &x); |
---|
| 594 | |
---|
| 595 | return ret; |
---|
| 596 | } |
---|
| 597 | |
---|
[19a023f] | 598 | /* replace 'replace' characters at the point with s, returning the change in size */ |
---|
[77f605d] | 599 | int owl_editwin_replace(owl_editwin *e, int replace, char *s) |
---|
[ebf0128] | 600 | { |
---|
[19a023f] | 601 | int start, end, i; |
---|
[5b5f3e6] | 602 | char *p; |
---|
[e9bb404] | 603 | |
---|
[5b5f3e6] | 604 | if (!g_utf8_validate(s, -1, NULL)) { |
---|
| 605 | owl_function_debugmsg("owl_editwin_insert_string: received non-utf-8 string."); |
---|
[ebf0128] | 606 | return 0; |
---|
[47519e1b] | 607 | } |
---|
| 608 | |
---|
[5b5f3e6] | 609 | start = e->index; |
---|
| 610 | for (i = 0, p = e->buff + start; i < replace && p != NULL; i++) |
---|
| 611 | p = oe_next_point(e, p); |
---|
| 612 | if (p != NULL) |
---|
| 613 | end = p - e->buff; |
---|
| 614 | else |
---|
| 615 | end = e->bufflen; |
---|
| 616 | |
---|
[19a023f] | 617 | return owl_editwin_replace_internal(e, end - start, s); |
---|
| 618 | } |
---|
| 619 | |
---|
| 620 | static int owl_editwin_replace_internal(owl_editwin *e, int replace, char *s) |
---|
| 621 | { |
---|
| 622 | int start, end, free, need, size, change; |
---|
| 623 | oe_excursion *x; |
---|
| 624 | char *p; |
---|
| 625 | |
---|
| 626 | start = e->index; |
---|
| 627 | end = start + replace; |
---|
| 628 | |
---|
[5b5f3e6] | 629 | free = e->allocated - e->bufflen + end - start; |
---|
| 630 | |
---|
| 631 | need = strlen(s) - free; |
---|
| 632 | if (need > 0) { |
---|
| 633 | size = e->allocated + need + INCR - (need % INCR); |
---|
[a60edf2] | 634 | p = owl_realloc(e->buff, size); |
---|
[5b5f3e6] | 635 | if (p == NULL) { |
---|
| 636 | /* XXX signal impending doom somehow and don't do anything */ |
---|
[ebf0128] | 637 | return 0; |
---|
[e9bb404] | 638 | } |
---|
[5b5f3e6] | 639 | e->buff = p; |
---|
| 640 | e->allocated = size; |
---|
[47519e1b] | 641 | } |
---|
[e9bb404] | 642 | |
---|
[5b5f3e6] | 643 | memmove(e->buff + start + strlen(s), e->buff + end, e->bufflen + 1 - end); |
---|
| 644 | memcpy(e->buff + start, s, strlen(s)); |
---|
[ebf0128] | 645 | change = start - end + strlen(s); |
---|
| 646 | e->bufflen += change; |
---|
[5b5f3e6] | 647 | e->index += strlen(s); |
---|
[ebf0128] | 648 | |
---|
[7f0c26f] | 649 | /* fix up the mark */ |
---|
[3e36085] | 650 | oe_fixup(&e->mark, start, end, change); |
---|
| 651 | oe_fixup(&e->topindex, start, end, change); |
---|
[ebf0128] | 652 | /* fix up any saved points after the replaced area */ |
---|
[7f0c26f] | 653 | for (x = e->excursions; x != NULL; x = x->next) { |
---|
| 654 | oe_fixup(&x->index, start, end, change); |
---|
[3e36085] | 655 | oe_fixup(&x->mark, start, end, change); |
---|
[7f0c26f] | 656 | } |
---|
[ebf0128] | 657 | |
---|
| 658 | return change; |
---|
[47519e1b] | 659 | } |
---|
| 660 | |
---|
[c9334b1] | 661 | /* linewrap the word just before the cursor. |
---|
| 662 | * returns 0 on success |
---|
| 663 | * returns -1 if we could not wrap. |
---|
| 664 | */ |
---|
[fc2677b] | 665 | static void _owl_editwin_linewrap_word(owl_editwin *e) |
---|
[c9334b1] | 666 | { |
---|
[fc2677b] | 667 | oe_excursion x; |
---|
[84027015] | 668 | gunichar c; |
---|
[7d4fbcd] | 669 | |
---|
[fc2677b] | 670 | oe_save_excursion(e, &x); |
---|
[84027015] | 671 | |
---|
[fc2677b] | 672 | while (owl_editwin_point_move(e, -1)) { |
---|
| 673 | c = owl_editwin_get_char_at_point(e); |
---|
| 674 | if (owl_util_can_break_after(c) || c == '\n') { |
---|
| 675 | if (c != '\n') |
---|
| 676 | owl_editwin_replace(e, c != ' ' ? 0 : 1, "\n"); |
---|
| 677 | break; |
---|
[2d4ff14] | 678 | } |
---|
[7d4fbcd] | 679 | } |
---|
[fc2677b] | 680 | |
---|
| 681 | oe_restore_excursion(e, &x); |
---|
[7d4fbcd] | 682 | } |
---|
| 683 | |
---|
[c9334b1] | 684 | /* delete the character at the current point, following chars |
---|
| 685 | * shift left. |
---|
[e20d8179] | 686 | */ |
---|
[c9334b1] | 687 | void owl_editwin_delete_char(owl_editwin *e) |
---|
| 688 | { |
---|
[5b5f3e6] | 689 | owl_editwin_replace(e, 1, ""); |
---|
[7d4fbcd] | 690 | } |
---|
| 691 | |
---|
[c9334b1] | 692 | /* Swap the character at point with the character at point-1 and |
---|
| 693 | * advance the pointer. If point is at beginning of buffer do |
---|
| 694 | * nothing. If point is after the last character swap point-1 with |
---|
[e20d8179] | 695 | * point-2. (Behaves as observed in tcsh and emacs). |
---|
[c9334b1] | 696 | */ |
---|
| 697 | void owl_editwin_transpose_chars(owl_editwin *e) |
---|
| 698 | { |
---|
[5b5f3e6] | 699 | char *middle, *end, *start, *tmp; |
---|
[f2e36b5] | 700 | |
---|
[47519e1b] | 701 | if (e->bufflen == 0) return; |
---|
[e20d8179] | 702 | |
---|
[5b5f3e6] | 703 | if (e->index == e->bufflen) |
---|
| 704 | owl_editwin_point_move(e, -1); /* point is after last character */ |
---|
[f2e36b5] | 705 | |
---|
[5b5f3e6] | 706 | if (owl_editwin_at_beginning_of_buffer(e)) |
---|
| 707 | return; /* point is at beginning of buffer, do nothing */ |
---|
[f2e36b5] | 708 | |
---|
[47519e1b] | 709 | /* Transpose two utf-8 unicode glyphs. */ |
---|
[5b5f3e6] | 710 | middle = e->buff + e->index; |
---|
[47519e1b] | 711 | |
---|
[5b5f3e6] | 712 | end = oe_next_point(e, middle); |
---|
| 713 | if (end == NULL) |
---|
[e20d8179] | 714 | return; |
---|
[47519e1b] | 715 | |
---|
[5b5f3e6] | 716 | start = oe_prev_point(e, middle); |
---|
| 717 | if (start == NULL) |
---|
[e20d8179] | 718 | return; |
---|
[47519e1b] | 719 | |
---|
[5b5f3e6] | 720 | tmp = owl_malloc((end - start) + 1); |
---|
| 721 | tmp[(end - start)] = 0; |
---|
| 722 | memcpy(tmp, middle, end - middle); |
---|
| 723 | memcpy(tmp + (end - middle), start, middle - start); |
---|
| 724 | |
---|
| 725 | owl_editwin_point_move(e, -1); |
---|
| 726 | owl_editwin_replace(e, 2, tmp); |
---|
[f2e36b5] | 727 | } |
---|
| 728 | |
---|
[c9334b1] | 729 | /* insert 'string' at the current point, later text is shifted |
---|
| 730 | * right |
---|
| 731 | */ |
---|
[5b5f3e6] | 732 | void owl_editwin_insert_string(owl_editwin *e, char *s) |
---|
[c9334b1] | 733 | { |
---|
[5b5f3e6] | 734 | owl_editwin_replace(e, 0, s); |
---|
[7d4fbcd] | 735 | } |
---|
| 736 | |
---|
[a556caa] | 737 | /* We assume index is not set to point to a mid-char */ |
---|
[bab52da] | 738 | static gunichar owl_editwin_get_char_at_point(owl_editwin *e) |
---|
[c9334b1] | 739 | { |
---|
[a556caa] | 740 | return g_utf8_get_char(e->buff + e->index); |
---|
| 741 | } |
---|
[7d4fbcd] | 742 | |
---|
[7f0c26f] | 743 | void owl_editwin_exchange_point_and_mark(owl_editwin *e) { |
---|
| 744 | int tmp; |
---|
| 745 | |
---|
| 746 | if (e->mark != -1) { |
---|
| 747 | tmp = e->mark; |
---|
| 748 | owl_editwin_set_mark(e); |
---|
| 749 | oe_set_index(e, tmp); |
---|
| 750 | } |
---|
| 751 | } |
---|
| 752 | |
---|
[e20d8179] | 753 | int owl_editwin_point_move(owl_editwin *e, int delta) |
---|
[84027015] | 754 | { |
---|
[e20d8179] | 755 | char *p; |
---|
[19f765d] | 756 | int change, d = 0; |
---|
[a556caa] | 757 | |
---|
| 758 | change = MAX(delta, - delta); |
---|
| 759 | p = e->buff + e->index; |
---|
| 760 | |
---|
| 761 | while (d < change && p != NULL) { |
---|
[e20d8179] | 762 | if (delta > 0) |
---|
| 763 | p = oe_next_point(e, p); |
---|
| 764 | else |
---|
| 765 | p = oe_prev_point(e, p); |
---|
| 766 | if (p != NULL) { |
---|
[521bc84] | 767 | oe_set_index(e, p - e->buff); |
---|
[e20d8179] | 768 | d++; |
---|
[a556caa] | 769 | } |
---|
| 770 | } |
---|
| 771 | |
---|
| 772 | return delta > 0 ? d : -d; |
---|
[84027015] | 773 | } |
---|
| 774 | |
---|
[a556caa] | 775 | int owl_editwin_at_beginning_of_buffer(owl_editwin *e) { |
---|
| 776 | if (e->index == e->lock) |
---|
| 777 | return 1; |
---|
[84027015] | 778 | |
---|
[a556caa] | 779 | return 0; |
---|
| 780 | } |
---|
| 781 | |
---|
| 782 | int owl_at_end_of_buffer(owl_editwin *e) { |
---|
| 783 | if (e->index == e->bufflen) |
---|
| 784 | return 1; |
---|
| 785 | |
---|
| 786 | return 0; |
---|
| 787 | } |
---|
| 788 | |
---|
| 789 | int owl_editwin_at_beginning_of_line(owl_editwin *e) /*noproto*/ |
---|
[c9334b1] | 790 | { |
---|
[a0fbdee] | 791 | oe_excursion x; |
---|
[a556caa] | 792 | int ret; |
---|
[47519e1b] | 793 | |
---|
[a556caa] | 794 | if (owl_editwin_at_beginning_of_buffer(e)) |
---|
| 795 | return 1; |
---|
[47519e1b] | 796 | |
---|
[a0fbdee] | 797 | oe_save_excursion(e, &x); |
---|
[a556caa] | 798 | owl_editwin_point_move(e, -1); |
---|
[bab52da] | 799 | ret = (owl_editwin_get_char_at_point(e) == '\n'); |
---|
[a0fbdee] | 800 | oe_restore_excursion(e, &x); |
---|
[a556caa] | 801 | |
---|
| 802 | return ret; |
---|
| 803 | } |
---|
| 804 | |
---|
[e20d8179] | 805 | static int owl_editwin_is_char_in(owl_editwin *e, char *set) |
---|
[a556caa] | 806 | { |
---|
| 807 | char *p; |
---|
[5b5f3e6] | 808 | |
---|
| 809 | for (p = set; *p != 0; p = g_utf8_find_next_char(p, NULL)) |
---|
| 810 | if (owl_editwin_get_char_at_point(e) == g_utf8_get_char(p)) |
---|
[a556caa] | 811 | return 1; |
---|
| 812 | return 0; |
---|
| 813 | } |
---|
| 814 | |
---|
[e20d8179] | 815 | int owl_editwin_move_if_in(owl_editwin *e, int delta, char *set) |
---|
[a556caa] | 816 | { |
---|
| 817 | int change, distance = 0; |
---|
[e20d8179] | 818 | while (owl_editwin_is_char_in(e, set)) { |
---|
[a556caa] | 819 | change = owl_editwin_point_move(e, delta); |
---|
| 820 | distance += change; |
---|
| 821 | if (change == 0) |
---|
| 822 | break; |
---|
[47519e1b] | 823 | } |
---|
[a556caa] | 824 | return distance; |
---|
| 825 | } |
---|
| 826 | |
---|
[e20d8179] | 827 | int owl_editwin_move_if_not_in(owl_editwin *e, int delta, char *set) |
---|
[a556caa] | 828 | { |
---|
| 829 | int change, distance = 0; |
---|
[e20d8179] | 830 | while (!owl_editwin_is_char_in(e, set)) { |
---|
[a556caa] | 831 | change = owl_editwin_point_move(e, delta); |
---|
| 832 | distance += change; |
---|
| 833 | if (change == 0) |
---|
| 834 | break; |
---|
[7d4fbcd] | 835 | } |
---|
[a556caa] | 836 | return distance; |
---|
[7d4fbcd] | 837 | } |
---|
| 838 | |
---|
[e20d8179] | 839 | int owl_editwin_move_to_beginning_of_line(owl_editwin *e) |
---|
[47519e1b] | 840 | { |
---|
[a556caa] | 841 | int distance = 0; |
---|
[47519e1b] | 842 | |
---|
[a556caa] | 843 | if (!owl_editwin_at_beginning_of_line(e)) { |
---|
| 844 | /* move off the \n if were at the end of a line */ |
---|
| 845 | distance += owl_editwin_point_move(e, -1); |
---|
| 846 | distance += owl_editwin_move_if_not_in(e, -1, "\n"); |
---|
| 847 | if (distance && !owl_editwin_at_beginning_of_buffer(e)) |
---|
| 848 | distance += owl_editwin_point_move(e, 1); |
---|
[47519e1b] | 849 | } |
---|
[77d4402] | 850 | e->goal_column = 0; /* subtleties */ |
---|
[84027015] | 851 | |
---|
[a556caa] | 852 | return distance; |
---|
| 853 | } |
---|
[e20d8179] | 854 | |
---|
| 855 | int owl_editwin_move_to_end_of_line(owl_editwin *e) |
---|
[a556caa] | 856 | { |
---|
| 857 | return owl_editwin_move_if_not_in(e, 1, "\n"); |
---|
[47519e1b] | 858 | } |
---|
| 859 | |
---|
[e20d8179] | 860 | int owl_editwin_line_move(owl_editwin *e, int delta) |
---|
[c9334b1] | 861 | { |
---|
[d7043b4] | 862 | int goal_column, change, ll, distance; |
---|
| 863 | int count = 0; |
---|
[a556caa] | 864 | |
---|
| 865 | change = MAX(delta, -delta); |
---|
| 866 | |
---|
[d7043b4] | 867 | goal_column = e->goal_column; |
---|
| 868 | distance = owl_editwin_move_to_beginning_of_line(e); |
---|
| 869 | goal_column = goal_column == -1 ? -distance : goal_column; |
---|
[a556caa] | 870 | |
---|
| 871 | while(count < change) { |
---|
| 872 | if (delta > 0) { |
---|
| 873 | distance += owl_editwin_move_if_not_in(e, 1, "\n"); |
---|
| 874 | distance += owl_editwin_point_move(e, 1); |
---|
| 875 | } else { |
---|
| 876 | /* I really want to assert delta < 0 here */ |
---|
| 877 | distance += owl_editwin_point_move(e, -1); /* to the newline on |
---|
| 878 | the previous line */ |
---|
| 879 | distance += owl_editwin_move_to_beginning_of_line(e); |
---|
| 880 | } |
---|
| 881 | count++; |
---|
[7d4fbcd] | 882 | } |
---|
[a556caa] | 883 | |
---|
| 884 | distance += (ll = owl_editwin_move_to_end_of_line(e)); |
---|
| 885 | if (ll > goal_column) |
---|
| 886 | distance += owl_editwin_point_move(e, goal_column - ll); |
---|
| 887 | |
---|
| 888 | e->goal_column = goal_column; |
---|
| 889 | |
---|
| 890 | return distance; |
---|
[7d4fbcd] | 891 | } |
---|
| 892 | |
---|
[c9334b1] | 893 | void owl_editwin_backspace(owl_editwin *e) |
---|
| 894 | { |
---|
[7d4fbcd] | 895 | /* delete the char before the current one |
---|
| 896 | * and shift later chars left |
---|
| 897 | */ |
---|
[a556caa] | 898 | if(owl_editwin_point_move(e, -1)) |
---|
[7d4fbcd] | 899 | owl_editwin_delete_char(e); |
---|
| 900 | } |
---|
| 901 | |
---|
[c9334b1] | 902 | void owl_editwin_key_up(owl_editwin *e) |
---|
| 903 | { |
---|
[a556caa] | 904 | owl_editwin_line_move(e, -1); |
---|
[7d4fbcd] | 905 | } |
---|
| 906 | |
---|
[c9334b1] | 907 | void owl_editwin_key_down(owl_editwin *e) |
---|
| 908 | { |
---|
[a556caa] | 909 | owl_editwin_line_move(e, 1); |
---|
[7d4fbcd] | 910 | } |
---|
| 911 | |
---|
[c9334b1] | 912 | void owl_editwin_key_left(owl_editwin *e) |
---|
| 913 | { |
---|
[a556caa] | 914 | owl_editwin_point_move(e, -1); |
---|
[7d4fbcd] | 915 | } |
---|
| 916 | |
---|
[c9334b1] | 917 | void owl_editwin_key_right(owl_editwin *e) |
---|
| 918 | { |
---|
[a556caa] | 919 | owl_editwin_point_move(e, 1); |
---|
[7d4fbcd] | 920 | } |
---|
| 921 | |
---|
[5b5f3e6] | 922 | int owl_editwin_forward_word(owl_editwin *e) |
---|
[c9334b1] | 923 | { |
---|
[5b5f3e6] | 924 | int distance; |
---|
[7d4fbcd] | 925 | /* if we're starting on a space, find the first non-space */ |
---|
[5b5f3e6] | 926 | distance = owl_editwin_move_if_in(e, 1, WHITESPACE); |
---|
[7d4fbcd] | 927 | |
---|
[a556caa] | 928 | /* now find the end of this word */ |
---|
[5b5f3e6] | 929 | distance += owl_editwin_move_if_not_in(e, 1, WHITESPACE); |
---|
| 930 | |
---|
| 931 | return distance; |
---|
| 932 | } |
---|
| 933 | |
---|
| 934 | void owl_editwin_move_to_nextword(owl_editwin *e) |
---|
| 935 | { |
---|
| 936 | owl_editwin_forward_word(e); |
---|
[7d4fbcd] | 937 | } |
---|
| 938 | |
---|
[c9334b1] | 939 | /* go backwards to the last non-space character |
---|
| 940 | */ |
---|
[5b5f3e6] | 941 | int owl_editwin_backward_word(owl_editwin *e) |
---|
[c9334b1] | 942 | { |
---|
[a0fbdee] | 943 | oe_excursion x; |
---|
[5b5f3e6] | 944 | int distance = 0; |
---|
| 945 | int further = 0; |
---|
[a556caa] | 946 | int beginning; |
---|
| 947 | /* if in middle of word, beginning of word */ |
---|
| 948 | |
---|
| 949 | /* if at beginning of a word, find beginning of previous word */ |
---|
| 950 | |
---|
[e20d8179] | 951 | if (owl_editwin_is_char_in(e, WHITESPACE)) { |
---|
[a556caa] | 952 | /* if in whitespace past end of word, find a word , the find the beginning*/ |
---|
[5b5f3e6] | 953 | distance += owl_editwin_move_if_in(e, -1, WHITESPACE); /* leaves us on the last |
---|
| 954 | character of the word */ |
---|
[a0fbdee] | 955 | oe_save_excursion(e, &x); |
---|
[a556caa] | 956 | /* are we at the beginning of a word? */ |
---|
| 957 | owl_editwin_point_move(e, -1); |
---|
[e20d8179] | 958 | beginning = owl_editwin_is_char_in(e, WHITESPACE); |
---|
[a0fbdee] | 959 | oe_restore_excursion(e, &x); |
---|
[a556caa] | 960 | if (beginning) |
---|
[5b5f3e6] | 961 | return distance; |
---|
[a556caa] | 962 | } else { |
---|
| 963 | /* in the middle of the word; */ |
---|
[a0fbdee] | 964 | oe_save_excursion(e, &x); |
---|
[5b5f3e6] | 965 | further += owl_editwin_point_move(e, -1); |
---|
[e20d8179] | 966 | if (owl_editwin_is_char_in(e, WHITESPACE)) { /* we were at the beginning */ |
---|
[5b5f3e6] | 967 | distance += owl_editwin_backward_word(e); /* previous case */ |
---|
[8321cb7] | 968 | oe_release_excursion(e, &x); |
---|
[5b5f3e6] | 969 | return distance + further; |
---|
[a556caa] | 970 | } else { |
---|
[a0fbdee] | 971 | oe_restore_excursion(e, &x); |
---|
[7d4fbcd] | 972 | } |
---|
| 973 | } |
---|
[5b5f3e6] | 974 | distance += owl_editwin_move_if_not_in(e, -1, WHITESPACE); |
---|
[a556caa] | 975 | /* will go past */ |
---|
| 976 | if (e->index > e->lock) |
---|
[5b5f3e6] | 977 | distance += owl_editwin_point_move(e, 1); |
---|
| 978 | return distance; |
---|
| 979 | } |
---|
| 980 | |
---|
| 981 | void owl_editwin_move_to_previousword(owl_editwin *e) |
---|
| 982 | { |
---|
| 983 | owl_editwin_backward_word(e); |
---|
[7d4fbcd] | 984 | } |
---|
| 985 | |
---|
[c9334b1] | 986 | void owl_editwin_delete_nextword(owl_editwin *e) |
---|
| 987 | { |
---|
[a0fbdee] | 988 | oe_excursion x; |
---|
[a556caa] | 989 | |
---|
[a0fbdee] | 990 | oe_save_excursion(e, &x); |
---|
[a60edf2] | 991 | oe_set_mark(e, e->index); |
---|
| 992 | owl_editwin_forward_word(e); |
---|
| 993 | owl_editwin_kill_region(e); |
---|
| 994 | oe_restore_mark_only(e, &x); |
---|
[7d4fbcd] | 995 | } |
---|
| 996 | |
---|
[c9334b1] | 997 | void owl_editwin_delete_previousword(owl_editwin *e) |
---|
| 998 | { |
---|
[a60edf2] | 999 | oe_excursion x; |
---|
[b68f9cd] | 1000 | |
---|
[a60edf2] | 1001 | oe_save_excursion(e, &x); |
---|
| 1002 | oe_set_mark(e, e->index); |
---|
| 1003 | owl_editwin_backward_word(e); |
---|
| 1004 | owl_editwin_kill_region(e); |
---|
| 1005 | oe_restore_mark_only(e, &x); |
---|
[b68f9cd] | 1006 | } |
---|
| 1007 | |
---|
[a556caa] | 1008 | void owl_editwin_move_to_line_end(owl_editwin *e) |
---|
[c9334b1] | 1009 | { |
---|
[a556caa] | 1010 | owl_editwin_move_to_end_of_line(e); |
---|
[7d4fbcd] | 1011 | } |
---|
| 1012 | |
---|
[a556caa] | 1013 | void owl_editwin_delete_to_endofline(owl_editwin *e) |
---|
[c9334b1] | 1014 | { |
---|
[a0fbdee] | 1015 | oe_excursion x; |
---|
[5b5f3e6] | 1016 | int distance; |
---|
[a556caa] | 1017 | |
---|
[a0fbdee] | 1018 | oe_save_excursion(e, &x); |
---|
[a60edf2] | 1019 | owl_editwin_set_mark(e); |
---|
[5b5f3e6] | 1020 | distance = owl_editwin_move_to_end_of_line(e); |
---|
[a60edf2] | 1021 | if (distance) |
---|
| 1022 | owl_editwin_kill_region(e); |
---|
| 1023 | else |
---|
| 1024 | owl_editwin_replace(e, 1, ""); |
---|
[a0fbdee] | 1025 | oe_restore_excursion(e, &x); |
---|
[a60edf2] | 1026 | } |
---|
| 1027 | |
---|
| 1028 | void owl_editwin_yank(owl_editwin *e) |
---|
| 1029 | { |
---|
| 1030 | if (e->killbuf != NULL) |
---|
| 1031 | owl_editwin_replace(e, 0, e->killbuf); |
---|
| 1032 | } |
---|
| 1033 | |
---|
| 1034 | static char *oe_copy_buf(owl_editwin *e, char *buf, int len) |
---|
| 1035 | { |
---|
| 1036 | char *p; |
---|
| 1037 | |
---|
| 1038 | p = owl_malloc(len + 1); |
---|
| 1039 | |
---|
| 1040 | if (p != NULL) { |
---|
| 1041 | owl_free(e->killbuf); |
---|
| 1042 | e->killbuf = p; |
---|
| 1043 | memcpy(e->killbuf, buf, len); |
---|
| 1044 | e->killbuf[len] = 0; |
---|
| 1045 | } |
---|
| 1046 | |
---|
| 1047 | return p; |
---|
| 1048 | } |
---|
| 1049 | |
---|
| 1050 | static int oe_copy_region(owl_editwin *e) |
---|
| 1051 | { |
---|
| 1052 | char *p; |
---|
| 1053 | int start, end; |
---|
| 1054 | |
---|
| 1055 | if (e->mark == -1) |
---|
| 1056 | return 0; |
---|
| 1057 | |
---|
| 1058 | start = MIN(e->index, e->mark); |
---|
| 1059 | end = MAX(e->index, e->mark); |
---|
| 1060 | |
---|
| 1061 | p = oe_copy_buf(e, e->buff + start, end - start); |
---|
| 1062 | if (p != NULL) |
---|
| 1063 | return end - start; |
---|
| 1064 | return 0; |
---|
| 1065 | } |
---|
| 1066 | |
---|
| 1067 | void owl_editwin_copy_region_as_kill(owl_editwin *e) |
---|
| 1068 | { |
---|
| 1069 | oe_copy_region(e); |
---|
| 1070 | } |
---|
| 1071 | |
---|
| 1072 | void owl_editwin_kill_region(owl_editwin *e) |
---|
| 1073 | { |
---|
| 1074 | if (e->index > e->mark) |
---|
| 1075 | owl_editwin_exchange_point_and_mark(e); |
---|
| 1076 | |
---|
| 1077 | owl_editwin_replace(e, oe_copy_region(e), ""); |
---|
[7d4fbcd] | 1078 | } |
---|
| 1079 | |
---|
[c9334b1] | 1080 | void owl_editwin_move_to_line_start(owl_editwin *e) |
---|
| 1081 | { |
---|
[a556caa] | 1082 | owl_editwin_move_to_beginning_of_line(e); |
---|
[7d4fbcd] | 1083 | } |
---|
| 1084 | |
---|
[c9334b1] | 1085 | void owl_editwin_move_to_end(owl_editwin *e) |
---|
| 1086 | { |
---|
[521bc84] | 1087 | oe_set_index(e, e->bufflen); |
---|
[7d4fbcd] | 1088 | } |
---|
| 1089 | |
---|
[c9334b1] | 1090 | void owl_editwin_move_to_top(owl_editwin *e) |
---|
| 1091 | { |
---|
[521bc84] | 1092 | oe_set_index(e, e->lock); |
---|
[7d4fbcd] | 1093 | } |
---|
| 1094 | |
---|
[2fc8397] | 1095 | void owl_editwin_backward_paragraph(owl_editwin *e) |
---|
| 1096 | { |
---|
| 1097 | owl_editwin_point_move(e, -1); |
---|
| 1098 | for (; e->index >= e->lock; owl_editwin_point_move(e, -1)) { |
---|
| 1099 | if (e->index <= e->lock || |
---|
| 1100 | ((e->buff[e->index] == '\n') && (e->buff[e->index - 1]=='\n'))) |
---|
| 1101 | break; |
---|
| 1102 | } |
---|
| 1103 | } |
---|
| 1104 | |
---|
| 1105 | void owl_editwin_forward_paragraph(owl_editwin *e) |
---|
| 1106 | { |
---|
| 1107 | owl_editwin_point_move(e, 1); |
---|
| 1108 | /* scan forward to the start of the next paragraph */ |
---|
| 1109 | for(; e->index < e->bufflen; owl_editwin_point_move(e, 1)) { |
---|
| 1110 | if (e->buff[e->index -1] == '\n' && e->buff[e->index] == '\n') |
---|
| 1111 | break; |
---|
| 1112 | } |
---|
| 1113 | } |
---|
| 1114 | |
---|
[fc2677b] | 1115 | static int oe_display_column(owl_editwin *e) |
---|
[c9334b1] | 1116 | { |
---|
[a0fbdee] | 1117 | oe_excursion x; |
---|
[fc2677b] | 1118 | int lineindex; |
---|
[7d4fbcd] | 1119 | |
---|
[a0fbdee] | 1120 | oe_save_excursion(e, &x); |
---|
[fc2677b] | 1121 | owl_editwin_move_to_beginning_of_line(e); |
---|
| 1122 | lineindex = e->index; |
---|
| 1123 | oe_restore_excursion(e, &x); |
---|
| 1124 | return oe_region_width(e, lineindex, e->index, 0); |
---|
| 1125 | } |
---|
[a556caa] | 1126 | |
---|
[fc2677b] | 1127 | void owl_editwin_fill_paragraph(owl_editwin *e) |
---|
| 1128 | { |
---|
| 1129 | oe_excursion x; |
---|
| 1130 | gunichar ch; |
---|
| 1131 | int sentence; |
---|
[7d4fbcd] | 1132 | |
---|
[fc2677b] | 1133 | oe_save_excursion(e, &x); |
---|
[7d4fbcd] | 1134 | |
---|
[fc2677b] | 1135 | /* Mark the end of the paragraph */ |
---|
| 1136 | owl_editwin_forward_paragraph(e); |
---|
| 1137 | /* Skip the trailing newline */ |
---|
| 1138 | owl_editwin_point_move(e, -1); |
---|
| 1139 | owl_editwin_set_mark(e); |
---|
[7d4fbcd] | 1140 | |
---|
[fc2677b] | 1141 | owl_editwin_backward_paragraph(e); |
---|
[7d4fbcd] | 1142 | |
---|
[fc2677b] | 1143 | /* Don't mess with the leading newline */ |
---|
| 1144 | if (owl_editwin_get_char_at_point(e) == '\n') |
---|
| 1145 | owl_editwin_point_move(e, 1); |
---|
[7d4fbcd] | 1146 | |
---|
[fc2677b] | 1147 | /* |
---|
| 1148 | * First pass: Scan forward replacing all series of spaces with ' ' |
---|
| 1149 | * (or nothing after CJK ideograms) |
---|
| 1150 | */ |
---|
| 1151 | sentence = 0; |
---|
| 1152 | for(;e->index < e->mark; owl_editwin_point_move(e, 1)) { |
---|
[50e671c] | 1153 | /* bail if we hit a trailing dot on the buffer */ |
---|
[fc2677b] | 1154 | if (strcmp(e->buff + e->index, "\n.") == 0) { |
---|
| 1155 | owl_editwin_set_mark(e); |
---|
[50e671c] | 1156 | break; |
---|
[7d4fbcd] | 1157 | } |
---|
| 1158 | |
---|
[fc2677b] | 1159 | ch = owl_editwin_get_char_at_point(e); |
---|
[b2c1bd4] | 1160 | |
---|
[fc2677b] | 1161 | if (owl_util_can_break_after(ch) || ch == '\n') { |
---|
| 1162 | if (g_unichar_isspace(ch)) { |
---|
| 1163 | owl_editwin_replace(e, 1, " "); |
---|
| 1164 | } |
---|
| 1165 | |
---|
| 1166 | if (sentence) |
---|
| 1167 | owl_editwin_point_move(e, 1); |
---|
| 1168 | |
---|
| 1169 | while(g_unichar_isspace(owl_editwin_get_char_at_point(e)) |
---|
| 1170 | && e->index < e->mark) { |
---|
| 1171 | owl_editwin_delete_char(e); |
---|
[7d4fbcd] | 1172 | } |
---|
| 1173 | } |
---|
[fc2677b] | 1174 | |
---|
| 1175 | if(ch == '.' || ch == '!' || ch == '?') |
---|
| 1176 | sentence = 1; |
---|
| 1177 | else |
---|
| 1178 | sentence = 0; |
---|
| 1179 | } |
---|
| 1180 | |
---|
| 1181 | owl_editwin_backward_paragraph(e); |
---|
| 1182 | |
---|
| 1183 | /* Now go through inserting newlines as needed */ |
---|
| 1184 | while(e->index < e->mark) { |
---|
| 1185 | /* if we've travelled too far, linewrap */ |
---|
| 1186 | if (oe_display_column(e) >= e->fillcol) |
---|
| 1187 | _owl_editwin_linewrap_word(e); |
---|
| 1188 | owl_editwin_point_move(e, 1); |
---|
[7d4fbcd] | 1189 | } |
---|
| 1190 | |
---|
[a0fbdee] | 1191 | oe_restore_excursion(e, &x); |
---|
[7d4fbcd] | 1192 | } |
---|
| 1193 | |
---|
[cf83b7a] | 1194 | /* returns true if only whitespace remains */ |
---|
[c9334b1] | 1195 | int owl_editwin_is_at_end(owl_editwin *e) |
---|
| 1196 | { |
---|
[a556caa] | 1197 | return (only_whitespace(e->buff + e->index)); |
---|
[217a43e] | 1198 | } |
---|
| 1199 | |
---|
[bab52da] | 1200 | static int owl_editwin_check_dotsend(owl_editwin *e) |
---|
[c9334b1] | 1201 | { |
---|
[47519e1b] | 1202 | char *p, *p_n, *p_p; |
---|
| 1203 | gunichar c; |
---|
[7d4fbcd] | 1204 | |
---|
| 1205 | if (!e->dotsend) return(0); |
---|
[47519e1b] | 1206 | |
---|
| 1207 | p = g_utf8_find_prev_char(e->buff, e->buff + e->bufflen); |
---|
| 1208 | p_n = g_utf8_find_next_char(p, NULL); |
---|
| 1209 | p_p = g_utf8_find_prev_char(e->buff, p); |
---|
| 1210 | c = g_utf8_get_char(p); |
---|
| 1211 | while (p != NULL) { |
---|
| 1212 | if (*p == '.' |
---|
| 1213 | && p_p != NULL && (*p_p == '\n' || *p_p == '\r') |
---|
| 1214 | && p_n != NULL && (*p_n == '\n' || *p_n == '\r')) { |
---|
| 1215 | e->bufflen = p - e->buff; |
---|
| 1216 | e->buff[e->bufflen] = '\0'; |
---|
[7d4fbcd] | 1217 | return(1); |
---|
| 1218 | } |
---|
[47519e1b] | 1219 | if (c != '\0' && !g_unichar_isspace(c)) return(0); |
---|
| 1220 | p_n = p; |
---|
| 1221 | p = p_p; |
---|
| 1222 | c = g_utf8_get_char(p); |
---|
| 1223 | p_p = g_utf8_find_prev_char(e->buff, p); |
---|
[7d4fbcd] | 1224 | } |
---|
| 1225 | return(0); |
---|
| 1226 | } |
---|
| 1227 | |
---|
[fac5463] | 1228 | void owl_editwin_post_process_char(owl_editwin *e, owl_input j) |
---|
[c9334b1] | 1229 | { |
---|
[a556caa] | 1230 | /* XXX force a redisplay? */ |
---|
[fac5463] | 1231 | if ((j.ch==13 || j.ch==10) && owl_editwin_check_dotsend(e)) { |
---|
[7d4fbcd] | 1232 | owl_command_editmulti_done(e); |
---|
| 1233 | return; |
---|
| 1234 | } |
---|
[e20d8179] | 1235 | owl_editwin_redisplay(e, 0); |
---|
[7d4fbcd] | 1236 | } |
---|
| 1237 | |
---|
[3e36085] | 1238 | static int oe_region_width(owl_editwin *e, int start, int end, int offset) |
---|
[16cfd12a] | 1239 | { |
---|
| 1240 | char *p; |
---|
[3e36085] | 1241 | int width = offset; |
---|
| 1242 | |
---|
[16cfd12a] | 1243 | for(p = e->buff + start; |
---|
| 1244 | p < e->buff + end; |
---|
| 1245 | p = g_utf8_find_next_char(p, NULL)) |
---|
| 1246 | width += oe_char_width(g_utf8_get_char(p), width); |
---|
| 1247 | |
---|
[3e36085] | 1248 | return width - offset; |
---|
[16cfd12a] | 1249 | } |
---|
| 1250 | |
---|
[ebf0128] | 1251 | static void oe_insert_char(owl_editwin *e, gunichar c) |
---|
[fac5463] | 1252 | { |
---|
[16cfd12a] | 1253 | oe_excursion x; |
---|
[5b5f3e6] | 1254 | char tmp[7]; |
---|
[16cfd12a] | 1255 | int replaced = -1; |
---|
[5b5f3e6] | 1256 | |
---|
[ebf0128] | 1257 | if (c == '\r') /* translate CRs to NLs */ |
---|
| 1258 | c = '\n'; |
---|
| 1259 | |
---|
[16cfd12a] | 1260 | if (!g_unichar_iscntrl(c) || c == '\n' || c== '\t' ) { |
---|
[ebf0128] | 1261 | memset(tmp, 0, 7); |
---|
| 1262 | |
---|
| 1263 | if (c == '\n' && e->style == OWL_EDITWIN_STYLE_ONELINE) { |
---|
| 1264 | return; |
---|
| 1265 | } |
---|
| 1266 | |
---|
[16cfd12a] | 1267 | if (e->cursorx != -1 && e->cursorx + oe_char_width(c, e->cursorx) > e->wrapcol) { |
---|
| 1268 | /* XXX this is actually wrong: |
---|
| 1269 | * + If the line has been been wrapped, we can be past the wrap column but |
---|
| 1270 | * e->cursorx be much smaller. |
---|
| 1271 | * + If the user went back and inserted a bunch of stuff in the middle of |
---|
| 1272 | * the line, there may be more than one word past the wrap column. |
---|
| 1273 | */ |
---|
| 1274 | oe_save_excursion(e, &x); |
---|
| 1275 | |
---|
| 1276 | if (c == ' ' || c == '\t') { |
---|
| 1277 | owl_editwin_point_move(e, -1); |
---|
| 1278 | replaced = -owl_editwin_move_if_in(e, -1, " \t"); |
---|
| 1279 | if (!replaced) { |
---|
| 1280 | c = '\n'; |
---|
| 1281 | replaced = -1; |
---|
| 1282 | } |
---|
| 1283 | } else { |
---|
| 1284 | while(!owl_editwin_at_beginning_of_line(e)) { |
---|
| 1285 | owl_editwin_point_move(e, -1); |
---|
| 1286 | if (owl_util_can_break_after(owl_editwin_get_char_at_point(e))) { |
---|
| 1287 | replaced = -owl_editwin_move_if_in(e, -1, " \t"); |
---|
| 1288 | break; |
---|
| 1289 | } |
---|
| 1290 | } |
---|
| 1291 | if (owl_editwin_at_beginning_of_line(e)) |
---|
| 1292 | replaced = -1; |
---|
| 1293 | } |
---|
| 1294 | if (replaced && !owl_editwin_at_beginning_of_line(e)) |
---|
| 1295 | owl_editwin_point_move(e, 1); |
---|
| 1296 | if (replaced >= 0) { |
---|
| 1297 | owl_editwin_replace(e, replaced, "\n"); |
---|
| 1298 | } |
---|
| 1299 | oe_restore_excursion(e, &x); |
---|
| 1300 | } |
---|
| 1301 | |
---|
| 1302 | if (replaced >= 0 && (c == ' ' || c == '\t')) |
---|
| 1303 | return; /* our work here is done */ |
---|
| 1304 | |
---|
[ebf0128] | 1305 | g_unichar_to_utf8(c, tmp); |
---|
| 1306 | owl_editwin_replace(e, 0, tmp); |
---|
| 1307 | } |
---|
| 1308 | } |
---|
| 1309 | |
---|
| 1310 | void owl_editwin_process_char(owl_editwin *e, owl_input j) |
---|
| 1311 | { |
---|
[5b5f3e6] | 1312 | if (j.ch == ERR) |
---|
| 1313 | return; |
---|
[fac5463] | 1314 | /* Ignore ncurses control characters. */ |
---|
[e20d8179] | 1315 | if (j.ch < 0x100) { |
---|
[ebf0128] | 1316 | oe_insert_char(e, j.uch); |
---|
[fac5463] | 1317 | } |
---|
| 1318 | } |
---|
| 1319 | |
---|
[c9334b1] | 1320 | char *owl_editwin_get_text(owl_editwin *e) |
---|
| 1321 | { |
---|
[7d4fbcd] | 1322 | return(e->buff+e->lock); |
---|
| 1323 | } |
---|
| 1324 | |
---|
[77f605d] | 1325 | int owl_editwin_get_echochar(owl_editwin *e) |
---|
| 1326 | { |
---|
[a556caa] | 1327 | return e->echochar; |
---|
| 1328 | } |
---|
[77f605d] | 1329 | |
---|
| 1330 | static char *oe_chunk(owl_editwin *e, int start, int end) |
---|
| 1331 | { |
---|
| 1332 | char *p; |
---|
| 1333 | |
---|
| 1334 | p = owl_malloc(end - start + 1); |
---|
| 1335 | memcpy(p, e->buff + start, end - start); |
---|
| 1336 | p[end - start] = 0; |
---|
| 1337 | |
---|
| 1338 | return p; |
---|
| 1339 | } |
---|
| 1340 | |
---|
| 1341 | char *owl_editwin_text_before_point(owl_editwin *e) |
---|
| 1342 | { |
---|
| 1343 | return oe_chunk(e, e->index < e->lock ? 0 : e->lock, e->index); |
---|
| 1344 | } |
---|
| 1345 | |
---|
| 1346 | char *owl_editwin_text_after_point(owl_editwin *e) |
---|
| 1347 | { |
---|
| 1348 | return oe_chunk(e, e->index, e->bufflen); |
---|
| 1349 | } |
---|
| 1350 | |
---|
[2f21a41] | 1351 | |
---|
| 1352 | /* |
---|
| 1353 | * Local Variables: |
---|
| 1354 | * mode:C |
---|
| 1355 | * c-basic-offset:2 |
---|
| 1356 | * End: |
---|
| 1357 | */ |
---|