Changeset 830c36e
- Timestamp:
- Jan 2, 2008, 10:51:28 PM (17 years ago)
- Branches:
- master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 3a7cf49
- Parents:
- 987a93c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
editwin.c
r47519e1b r830c36e 316 316 e->buff[e->bufflen] = '\0'; 317 317 } 318 318 319 /* Insert n bytes at cursor.*/ 319 320 void _owl_editwin_insert_bytes(owl_editwin *e, int n) /*noproto*/ … … 371 372 char tmp[6]; 372 373 memset(tmp, '\0', 6); 373 374 374 375 /* \r is \n */ 375 376 if (c == '\r') { … … 385 386 g_unichar_to_utf8(c, tmp); 386 387 len = strlen(tmp); 387 388 388 389 /* make sure there is enough memory for the new text */ 389 390 if ((e->bufflen + len) > (e->allocated - 5)) { … … 404 405 405 406 /* shift all the other characters right */ 406 _owl_editwin_insert_bytes(e, len); 407 if (z != e->bufflen) { 408 _owl_editwin_insert_bytes(e, len); 409 } 407 410 408 411 /* insert the new character */ … … 414 417 e->bufflen += len; 415 418 e->buff[e->bufflen] = '\0'; 416 419 417 420 /* advance the cursor */ 418 421 z += len; … … 426 429 char tmp[6]; 427 430 memset(tmp, '\0', 6); 428 431 429 432 /* \r is \n */ 430 433 if (c == '\r') { 431 434 c = '\n'; 432 435 } 433 436 434 437 if (c == '\n' && e->style == OWL_EDITWIN_STYLE_ONELINE) { 435 438 /* perhaps later this will change some state that allows the string … … 444 447 { 445 448 char *t = g_utf8_find_next_char(e->buff + z, NULL); 446 oldlen = (t ? (t - (e->buff + z)) : 1); 447 } 448 449 if ((e->bufflen + newlen - oldlen + 1) > (e->allocated - 5)) { 450 _owl_editwin_addspace(e); 451 } 452 453 if (oldlen > newlen) { 449 oldlen = (t ? (t - (e->buff + z)) : 0); 450 } 451 452 /* only if we are at the end of the buffer do we create new space here */ 453 if (z == e->bufflen) { 454 if ((e->bufflen+newlen) > (e->allocated-5)) { 455 _owl_editwin_addspace(e); 456 } 457 } 458 /* if not at the end of the buffer, adjust based in char size difference. */ 459 else if (oldlen > newlen) { 454 460 _owl_editwin_remove_bytes(e, oldlen-newlen); 455 461 } … … 463 469 464 470 /* housekeeping */ 465 e->buff[e->bufflen] = '\0'; 466 471 if (z == e->bufflen) { 472 e->bufflen += newlen; 473 e->buff[e->bufflen] = '\0'; 474 } 475 467 476 /* advance the cursor */ 468 477 z += newlen;
Note: See TracChangeset
for help on using the changeset viewer.