input.c (7e1b7636c894be9d1130c284089ce1ea0786ecec) | input.c (b2ea244070ff84eab79e04befb7aa30c982fc84d) |
---|---|
1/* 2 * Copyright (C) 1984-2017 Mark Nudelman 3 * 4 * You may distribute under the terms of either the GNU General Public 5 * License or the Less License, as specified in the README file. 6 * 7 * For more information, see the README file. 8 */ 9 | 1/* 2 * Copyright (C) 1984-2017 Mark Nudelman 3 * 4 * You may distribute under the terms of either the GNU General Public 5 * License or the Less License, as specified in the README file. 6 * 7 * For more information, see the README file. 8 */ 9 |
10 | |
11/* 12 * High level routines dealing with getting lines of input 13 * from the file being viewed. 14 * 15 * When we speak of "lines" here, we mean PRINTABLE lines; 16 * lines processed with respect to the screen width. 17 * We use the term "raw line" to refer to lines simply 18 * delimited by newlines; not processed with respect to screen width. --- 26 unchanged lines hidden (view full) --- 45forw_line(curr_pos) 46 POSITION curr_pos; 47{ 48 POSITION base_pos; 49 POSITION new_pos; 50 int c; 51 int blankline; 52 int endline; | 10/* 11 * High level routines dealing with getting lines of input 12 * from the file being viewed. 13 * 14 * When we speak of "lines" here, we mean PRINTABLE lines; 15 * lines processed with respect to the screen width. 16 * We use the term "raw line" to refer to lines simply 17 * delimited by newlines; not processed with respect to screen width. --- 26 unchanged lines hidden (view full) --- 44forw_line(curr_pos) 45 POSITION curr_pos; 46{ 47 POSITION base_pos; 48 POSITION new_pos; 49 int c; 50 int blankline; 51 int endline; |
52 int chopped; |
|
53 int backchars; 54 55get_forw_line: 56 if (curr_pos == NULL_POSITION) 57 { 58 null_line(); 59 return (NULL_POSITION); 60 } --- 77 unchanged lines hidden (view full) --- 138 null_line(); 139 return (NULL_POSITION); 140 } 141 blankline = (c == '\n' || c == '\r'); 142 143 /* 144 * Read each character in the line and append to the line buffer. 145 */ | 53 int backchars; 54 55get_forw_line: 56 if (curr_pos == NULL_POSITION) 57 { 58 null_line(); 59 return (NULL_POSITION); 60 } --- 77 unchanged lines hidden (view full) --- 138 null_line(); 139 return (NULL_POSITION); 140 } 141 blankline = (c == '\n' || c == '\r'); 142 143 /* 144 * Read each character in the line and append to the line buffer. 145 */ |
146 chopped = FALSE; |
|
146 for (;;) 147 { 148 if (ABORT_SIGS()) 149 { 150 null_line(); 151 return (NULL_POSITION); 152 } 153 if (c == '\n' || c == EOI) --- 34 unchanged lines hidden (view full) --- 188 null_line(); 189 return (NULL_POSITION); 190 } 191 c = ch_forw_get(); 192 } while (c != '\n' && c != EOI); 193 new_pos = ch_tell(); 194 endline = TRUE; 195 quit_if_one_screen = FALSE; | 147 for (;;) 148 { 149 if (ABORT_SIGS()) 150 { 151 null_line(); 152 return (NULL_POSITION); 153 } 154 if (c == '\n' || c == EOI) --- 34 unchanged lines hidden (view full) --- 189 null_line(); 190 return (NULL_POSITION); 191 } 192 c = ch_forw_get(); 193 } while (c != '\n' && c != EOI); 194 new_pos = ch_tell(); 195 endline = TRUE; 196 quit_if_one_screen = FALSE; |
197 chopped = TRUE; |
|
196 } else 197 { 198 new_pos = ch_tell() - backchars; 199 endline = FALSE; 200 } 201 break; 202 } 203 c = ch_forw_get(); 204 } 205 | 198 } else 199 { 200 new_pos = ch_tell() - backchars; 201 endline = FALSE; 202 } 203 break; 204 } 205 c = ch_forw_get(); 206 } 207 |
206 pdone(endline, 1); | 208 pdone(endline, chopped, 1); |
207 208#if HILITE_SEARCH 209 if (is_filtered(base_pos)) 210 { 211 /* 212 * We don't want to display this line. 213 * Get the next line. 214 */ --- 35 unchanged lines hidden (view full) --- 250 */ 251 public POSITION 252back_line(curr_pos) 253 POSITION curr_pos; 254{ 255 POSITION new_pos, begin_new_pos, base_pos; 256 int c; 257 int endline; | 209 210#if HILITE_SEARCH 211 if (is_filtered(base_pos)) 212 { 213 /* 214 * We don't want to display this line. 215 * Get the next line. 216 */ --- 35 unchanged lines hidden (view full) --- 252 */ 253 public POSITION 254back_line(curr_pos) 255 POSITION curr_pos; 256{ 257 POSITION new_pos, begin_new_pos, base_pos; 258 int c; 259 int endline; |
260 int chopped; |
|
258 int backchars; 259 260get_back_line: 261 if (curr_pos == NULL_POSITION || curr_pos <= ch_zero()) 262 { 263 null_line(); 264 return (NULL_POSITION); 265 } --- 88 unchanged lines hidden (view full) --- 354 return (NULL_POSITION); 355 } 356 endline = FALSE; 357 prewind(); 358 plinenum(new_pos); 359 loop: 360 begin_new_pos = new_pos; 361 (void) ch_seek(new_pos); | 261 int backchars; 262 263get_back_line: 264 if (curr_pos == NULL_POSITION || curr_pos <= ch_zero()) 265 { 266 null_line(); 267 return (NULL_POSITION); 268 } --- 88 unchanged lines hidden (view full) --- 357 return (NULL_POSITION); 358 } 359 endline = FALSE; 360 prewind(); 361 plinenum(new_pos); 362 loop: 363 begin_new_pos = new_pos; 364 (void) ch_seek(new_pos); |
365 chopped = FALSE; |
|
362 363 do 364 { 365 c = ch_forw_get(); 366 if (c == EOI || ABORT_SIGS()) 367 { 368 null_line(); 369 return (NULL_POSITION); --- 16 unchanged lines hidden (view full) --- 386 /* 387 * Got a full printable line, but we haven't 388 * reached our curr_pos yet. Discard the line 389 * and start a new one. 390 */ 391 if (chopline || hshift > 0) 392 { 393 endline = TRUE; | 366 367 do 368 { 369 c = ch_forw_get(); 370 if (c == EOI || ABORT_SIGS()) 371 { 372 null_line(); 373 return (NULL_POSITION); --- 16 unchanged lines hidden (view full) --- 390 /* 391 * Got a full printable line, but we haven't 392 * reached our curr_pos yet. Discard the line 393 * and start a new one. 394 */ 395 if (chopline || hshift > 0) 396 { 397 endline = TRUE; |
398 chopped = TRUE; |
|
394 quit_if_one_screen = FALSE; 395 break; 396 } 397 shift: 398 pshift_all(); 399 while (backchars-- > 0) 400 { 401 (void) ch_back_get(); 402 new_pos--; 403 } 404 goto loop; 405 } 406 } while (new_pos < curr_pos); 407 | 399 quit_if_one_screen = FALSE; 400 break; 401 } 402 shift: 403 pshift_all(); 404 while (backchars-- > 0) 405 { 406 (void) ch_back_get(); 407 new_pos--; 408 } 409 goto loop; 410 } 411 } while (new_pos < curr_pos); 412 |
408 pdone(endline, 0); | 413 pdone(endline, chopped, 0); |
409 410#if HILITE_SEARCH 411 if (is_filtered(base_pos)) 412 { 413 /* 414 * We don't want to display this line. 415 * Get the previous line. 416 */ --- 47 unchanged lines hidden --- | 414 415#if HILITE_SEARCH 416 if (is_filtered(base_pos)) 417 { 418 /* 419 * We don't want to display this line. 420 * Get the previous line. 421 */ --- 47 unchanged lines hidden --- |