=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/less/input.c,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.2 diff -c -r1.1.1.1 -r1.1.1.2 *** src/usr.bin/less/input.c 1996/09/21 05:39:42 1.1.1.1 --- src/usr.bin/less/input.c 2003/04/13 18:21:21 1.1.1.2 *************** *** 1,27 **** /* ! * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman ! * All rights reserved. * ! * Redistribution and use in source and binary forms, with or without ! * modification, are permitted provided that the following conditions ! * are met: ! * 1. Redistributions of source code must retain the above copyright ! * notice, this list of conditions and the following disclaimer. ! * 2. Redistributions in binary form must reproduce the above copyright ! * notice in the documentation and/or other materials provided with ! * the distribution. * ! * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY ! * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ! * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR ! * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE ! * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ! * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ! * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ! * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ! * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ! * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ! * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ --- 1,11 ---- /* ! * Copyright (C) 1984-2002 Mark Nudelman * ! * You may distribute under the terms of either the GNU General Public ! * License or the Less License, as specified in the README file. * ! * For more information about less, or for information on how to ! * contact the author, see the README file. */ *************** *** 39,45 **** --- 23,34 ---- extern int squeeze; extern int chopline; + extern int hshift; + extern int quit_if_one_screen; extern int sigs; + extern int ignore_eoi; + extern POSITION start_attnpos; + extern POSITION end_attnpos; #if HILITE_SEARCH extern int hilite_search; extern int size_linebuf; *************** *** 68,74 **** } #if HILITE_SEARCH if (hilite_search == OPT_ONPLUS) ! prep_hilite(curr_pos, curr_pos + 3*size_linebuf); #endif if (ch_seek(curr_pos)) { --- 57,71 ---- } #if HILITE_SEARCH if (hilite_search == OPT_ONPLUS) ! /* ! * If we are ignoring EOI (command F), only prepare ! * one line ahead, to avoid getting stuck waiting for ! * slow data without displaying the data we already have. ! * If we're not ignoring EOI, we *could* do the same, but ! * for efficiency we prepare several lines ahead at once. ! */ ! prep_hilite(curr_pos, curr_pos + 3*size_linebuf, ! ignore_eoi ? 1 : -1); #endif if (ch_seek(curr_pos)) { *************** *** 101,107 **** * End of the line. */ new_pos = ch_tell(); ! endline = 1; break; } --- 98,104 ---- * End of the line. */ new_pos = ch_tell(); ! endline = TRUE; break; } *************** *** 115,132 **** * is too long to print in the screen width. * End the line here. */ ! if (chopline) { do { c = ch_forw_get(); } while (c != '\n' && c != EOI); new_pos = ch_tell(); ! endline = 1; } else { new_pos = ch_tell() - 1; ! endline = 0; } break; } --- 112,130 ---- * is too long to print in the screen width. * End the line here. */ ! if (chopline || hshift > 0) { do { c = ch_forw_get(); } while (c != '\n' && c != EOI); new_pos = ch_tell(); ! endline = TRUE; ! quit_if_one_screen = FALSE; } else { new_pos = ch_tell() - 1; ! endline = FALSE; } break; } *************** *** 178,184 **** #if HILITE_SEARCH if (hilite_search == OPT_ONPLUS) prep_hilite((curr_pos < 3*size_linebuf) ? ! 0 : curr_pos - 3*size_linebuf, curr_pos); #endif if (ch_seek(curr_pos-1)) { --- 176,182 ---- #if HILITE_SEARCH if (hilite_search == OPT_ONPLUS) prep_hilite((curr_pos < 3*size_linebuf) ? ! 0 : curr_pos - 3*size_linebuf, curr_pos, -1); #endif if (ch_seek(curr_pos-1)) { *************** *** 264,270 **** null_line(); return (NULL_POSITION); } ! endline = 0; loop: begin_new_pos = new_pos; prewind(); --- 262,268 ---- null_line(); return (NULL_POSITION); } ! endline = FALSE; loop: begin_new_pos = new_pos; prewind(); *************** *** 282,288 **** new_pos++; if (c == '\n') { ! endline = 1; break; } if (pappend(c, ch_tell()-1)) --- 280,286 ---- new_pos++; if (c == '\n') { ! endline = TRUE; break; } if (pappend(c, ch_tell()-1)) *************** *** 292,300 **** * reached our curr_pos yet. Discard the line * and start a new one. */ ! if (chopline) { ! endline = 1; break; } pdone(0); --- 290,299 ---- * reached our curr_pos yet. Discard the line * and start a new one. */ ! if (chopline || hshift > 0) { ! endline = TRUE; ! quit_if_one_screen = FALSE; break; } pdone(0); *************** *** 307,310 **** --- 306,343 ---- pdone(endline); return (begin_new_pos); + } + + /* + * Set attnpos. + */ + public void + set_attnpos(pos) + POSITION pos; + { + int c; + + if (pos != NULL_POSITION) + { + if (ch_seek(pos)) + return; + for (;;) + { + c = ch_forw_get(); + if (c == EOI) + return; + if (c != '\n' && c != '\r') + break; + pos++; + } + } + start_attnpos = pos; + for (;;) + { + c = ch_forw_get(); + pos++; + if (c == EOI || c == '\n' || c == '\r') + break; + } + end_attnpos = pos; }