forwback.c (161478) | forwback.c (170259) |
---|---|
1/* $FreeBSD: head/contrib/less/forwback.c 161478 2006-08-20 15:50:51Z delphij $ */ | 1/* $FreeBSD: head/contrib/less/forwback.c 170259 2007-06-04 01:43:11Z delphij $ */ |
2/* | 2/* |
3 * Copyright (C) 1984-2005 Mark Nudelman | 3 * Copyright (C) 1984-2007 Mark Nudelman |
4 * 5 * You may distribute under the terms of either the GNU General Public 6 * License or the Less License, as specified in the README file. 7 * 8 * For more information about less, or for information on how to 9 * contact the author, see the README file. 10 */ 11 --- 5 unchanged lines hidden (view full) --- 17 18#include "less.h" 19#include "position.h" 20 21public int hit_eof; /* Keeps track of how many times we hit end of file */ 22public int screen_trashed; 23public int squished; 24public int no_back_scroll = 0; | 4 * 5 * You may distribute under the terms of either the GNU General Public 6 * License or the Less License, as specified in the README file. 7 * 8 * For more information about less, or for information on how to 9 * contact the author, see the README file. 10 */ 11 --- 5 unchanged lines hidden (view full) --- 17 18#include "less.h" 19#include "position.h" 20 21public int hit_eof; /* Keeps track of how many times we hit end of file */ 22public int screen_trashed; 23public int squished; 24public int no_back_scroll = 0; |
25public int forw_prompt; |
|
25 26extern int sigs; 27extern int top_scroll; 28extern int quiet; 29extern int sc_width, sc_height; | 26 27extern int sigs; 28extern int top_scroll; 29extern int quiet; 30extern int sc_width, sc_height; |
30extern int quit_at_eof; 31extern int more_mode; | 31extern int less_is_more; |
32extern int plusoption; 33extern int forw_scroll; 34extern int back_scroll; 35extern int ignore_eoi; 36extern int clear_bg; 37extern int final_attr; | 32extern int plusoption; 33extern int forw_scroll; 34extern int back_scroll; 35extern int ignore_eoi; 36extern int clear_bg; 37extern int final_attr; |
38extern int oldbot; |
|
38#if TAGS 39extern char *tagoption; 40#endif 41 42/* 43 * Sound the bell to indicate user is trying to move past end of file. 44 */ 45 static void --- 28 unchanged lines hidden (view full) --- 74} 75 76/* 77 * If the screen is "squished", repaint it. 78 * "Squished" means the first displayed line is not at the top 79 * of the screen; this can happen when we display a short file 80 * for the first time. 81 */ | 39#if TAGS 40extern char *tagoption; 41#endif 42 43/* 44 * Sound the bell to indicate user is trying to move past end of file. 45 */ 46 static void --- 28 unchanged lines hidden (view full) --- 75} 76 77/* 78 * If the screen is "squished", repaint it. 79 * "Squished" means the first displayed line is not at the top 80 * of the screen; this can happen when we display a short file 81 * for the first time. 82 */ |
82 static void | 83 public void |
83squish_check() 84{ 85 if (!squished) 86 return; 87 squished = 0; 88 repaint(); 89} 90 --- 41 unchanged lines hidden (view full) --- 132 * Start a new screen. 133 * {{ This is not really desirable if we happen 134 * to hit eof in the middle of this screen, 135 * but we don't yet know if that will happen. }} 136 */ 137 pos_clear(); 138 add_forw_pos(pos); 139 force = 1; | 84squish_check() 85{ 86 if (!squished) 87 return; 88 squished = 0; 89 repaint(); 90} 91 --- 41 unchanged lines hidden (view full) --- 133 * Start a new screen. 134 * {{ This is not really desirable if we happen 135 * to hit eof in the middle of this screen, 136 * but we don't yet know if that will happen. }} 137 */ 138 pos_clear(); 139 add_forw_pos(pos); 140 force = 1; |
140 if (more_mode == 0) 141 { 142 if (top_scroll == OPT_ONPLUS || (first_time && top_scroll != OPT_ON)) 143 clear(); | 141 if (less_is_more == 0) { 142 clear(); |
144 home(); 145 } 146 } else 147 { 148 clear_bot(); 149 } 150 151 if (pos != position(BOTTOM_PLUS_ONE) || empty_screen()) 152 { 153 /* 154 * This is not contiguous with what is 155 * currently displayed. Clear the screen image 156 * (position table) and start a new screen. 157 */ 158 pos_clear(); 159 add_forw_pos(pos); 160 force = 1; 161 if (top_scroll) 162 { | 143 home(); 144 } 145 } else 146 { 147 clear_bot(); 148 } 149 150 if (pos != position(BOTTOM_PLUS_ONE) || empty_screen()) 151 { 152 /* 153 * This is not contiguous with what is 154 * currently displayed. Clear the screen image 155 * (position table) and start a new screen. 156 */ 157 pos_clear(); 158 add_forw_pos(pos); 159 force = 1; 160 if (top_scroll) 161 { |
163 if (top_scroll == OPT_ONPLUS) 164 clear(); | 162 clear(); |
165 home(); 166 } else if (!first_time) 167 { 168 putstr("...skipping...\n"); 169 } 170 } 171 } 172 --- 48 unchanged lines hidden (view full) --- 221 * we hit an early EOF (i.e. before the requested 222 * number of lines), we "squish" the display down 223 * at the bottom of the screen. 224 * But don't do this if a + option or a -t option 225 * was given. These options can cause us to 226 * start the display after the beginning of the file, 227 * and it is not appropriate to squish in that case. 228 */ | 163 home(); 164 } else if (!first_time) 165 { 166 putstr("...skipping...\n"); 167 } 168 } 169 } 170 --- 48 unchanged lines hidden (view full) --- 219 * we hit an early EOF (i.e. before the requested 220 * number of lines), we "squish" the display down 221 * at the bottom of the screen. 222 * But don't do this if a + option or a -t option 223 * was given. These options can cause us to 224 * start the display after the beginning of the file, 225 * and it is not appropriate to squish in that case. 226 */ |
229 if ((first_time || more_mode) && | 227 if ((first_time || less_is_more) && |
230 pos == NULL_POSITION && !top_scroll && 231#if TAGS 232 tagoption == NULL && 233#endif 234 !plusoption) 235 { 236 squished = 1; 237 continue; 238 } | 228 pos == NULL_POSITION && !top_scroll && 229#if TAGS 230 tagoption == NULL && 231#endif 232 !plusoption) 233 { 234 squished = 1; 235 continue; 236 } |
239 if (top_scroll == OPT_ON) 240 clear_eol(); | |
241 put_line(); | 237 put_line(); |
238#if 0 239 /* {{ 240 * Can't call clear_eol here. The cursor might be at end of line 241 * on an ignaw terminal, so clear_eol would clear the last char 242 * of the current line instead of all of the next line. 243 * If we really need to do this on clear_bg terminals, we need 244 * to find a better way. 245 * }} 246 */ |
|
242 if (clear_bg && apply_at_specials(final_attr) != AT_NORMAL) 243 { 244 /* 245 * Writing the last character on the last line 246 * of the display may have scrolled the screen. 247 * If we were in standout mode, clear_bg terminals 248 * will fill the new line with the standout color. 249 * Now we're in normal mode again, so clear the line. 250 */ 251 clear_eol(); 252 } | 247 if (clear_bg && apply_at_specials(final_attr) != AT_NORMAL) 248 { 249 /* 250 * Writing the last character on the last line 251 * of the display may have scrolled the screen. 252 * If we were in standout mode, clear_bg terminals 253 * will fill the new line with the standout color. 254 * Now we're in normal mode again, so clear the line. 255 */ 256 clear_eol(); 257 } |
258#endif 259 forw_prompt = 1; |
|
253 } 254 255 if (ignore_eoi) 256 hit_eof = 0; 257 else if (eof && !ABORT_SIGS()) 258 hit_eof++; 259 else 260 eof_check(); --- 49 unchanged lines hidden (view full) --- 310 } 311 } 312 313 eof_check(); 314 if (nlines == 0) 315 eof_bell(); 316 else if (do_repaint) 317 repaint(); | 260 } 261 262 if (ignore_eoi) 263 hit_eof = 0; 264 else if (eof && !ABORT_SIGS()) 265 hit_eof++; 266 else 267 eof_check(); --- 49 unchanged lines hidden (view full) --- 317 } 318 } 319 320 eof_check(); 321 if (nlines == 0) 322 eof_bell(); 323 else if (do_repaint) 324 repaint(); |
325 else if (!oldbot) 326 lower_left(); |
|
318 (void) currline(BOTTOM); 319} 320 321/* 322 * Display n more lines, forward. 323 * Start just after the line currently displayed at the bottom of the screen. 324 */ 325 public void 326forward(n, force, only_last) 327 int n; 328 int force; 329 int only_last; 330{ 331 POSITION pos; 332 | 327 (void) currline(BOTTOM); 328} 329 330/* 331 * Display n more lines, forward. 332 * Start just after the line currently displayed at the bottom of the screen. 333 */ 334 public void 335forward(n, force, only_last) 336 int n; 337 int force; 338 int only_last; 339{ 340 POSITION pos; 341 |
333 if (quit_at_eof && hit_eof && !(ch_getflags() & CH_HELPFILE)) | 342 if (get_quit_at_eof() && hit_eof && !(ch_getflags() & CH_HELPFILE)) |
334 { 335 /* 336 * If the -e flag is set and we're trying to go 337 * forward from end-of-file, go on to the next file. 338 */ 339 if (edit_next(1)) 340 quit(QUIT_OK); 341 return; --- 70 unchanged lines hidden --- | 343 { 344 /* 345 * If the -e flag is set and we're trying to go 346 * forward from end-of-file, go on to the next file. 347 */ 348 if (edit_next(1)) 349 quit(QUIT_OK); 350 return; --- 70 unchanged lines hidden --- |