Added OA-U 'unwrap paragraph' function

This commit is contained in:
Bobbi Webber-Manners 2020-08-01 15:38:56 -04:00
parent 0239a03923
commit 04b4d29eef
2 changed files with 12 additions and 5 deletions

View File

@ -893,8 +893,10 @@ void page_up(void) {
/*
* Perform word-wrapping on current paragraph
* addbreaks - if 1, add breaks to do word wrap, otherwise it 'unwraps'
* (ie: removes all carriage returns in paragraph)
*/
void word_wrap_para() {
void word_wrap_para(uint8_t addbreaks) {
uint16_t i = gapbegin;
uint8_t rets = 0, col = 0;
uint16_t startpara = 0;
@ -916,7 +918,7 @@ void word_wrap_para() {
if (gapbuf[i] == '\r')
gapbuf[i] = ' ';
++col;
if (col == 76) {
if (addbreaks && (col == 76)) {
// Backtrack to find a space
while ((gapbuf[i] != ' ') && (i > startpara))
--i;
@ -1256,9 +1258,14 @@ int edit(char *fname) {
}
}
break;
case 0x80 + 'U': // OA-U "Unwrap"
case 0x80 + 'u': // OA-w
word_wrap_para(0);
draw_screen();
break;
case 0x80 + 'W': // OA-W "Wrap"
case 0x80 + 'w': // OA-w
word_wrap_para();
word_wrap_para(1);
draw_screen();
break;
case 0x80 + 'S': // OA-S "Save"

View File

@ -18,6 +18,6 @@
| @-N Set file name to save +----------------------------------------+
| @-Q Quit | Miscellaneous: |
| @-S Save file | @-W Word-wrap paragraph |
| | @-? This help |
| | Ctrl-L Refresh screen |
| | @-U Unwrap paragraph |
| @-? This help | Ctrl-L Refresh screen |
+-------------------------------------+----------------------------------------+