Skip to content

Commit

Permalink
Make status column display matches even if matched string
Browse files Browse the repository at this point in the history
is scrolled off screen because -S is in effect.
Still doesn't work quite right with wrapped lines.
I think it should display a star on ALL screen lines of the physical line.
  • Loading branch information
gwsw committed Feb 24, 2008
1 parent 66b639f commit 103b80c
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 38 deletions.
11 changes: 10 additions & 1 deletion NEWS.VER
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@
======================================================================


Major changes between "less" versions 416 and @@VERSION@@
Major changes between "less" versions 418 and @@VERSION@@

* Status column now displays a search match, even if the matched
string is scrolled off screen because -S is in effect.

* Fix bug in '' (quote, quote) command after G command.

======================================================================

Major changes between "less" versions 416 and 418

* Color escape sequences are now supported in WIN32 build.

Expand Down
53 changes: 28 additions & 25 deletions ch.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,38 +153,41 @@ fch_get()
/*
* Need more data in this buffer.
*/
goto read_more;
break;
goto found;
}
}
/*
* Block is not in a buffer.
* Take the least recently used buffer
* and read the desired block into it.
* If the LRU buffer has data in it,
* then maybe allocate a new buffer.
*/
if (ch_buftail == END_OF_CHAIN || ch_buftail->block != -1)
if (bp == END_OF_HCHAIN(h))
{
/*
* There is no empty buffer to use.
* Allocate a new buffer if:
* 1. We can't seek on this file and -b is not in effect; or
* 2. We haven't allocated the max buffers for this file yet.
* Block is not in a buffer.
* Take the least recently used buffer
* and read the desired block into it.
* If the LRU buffer has data in it,
* then maybe allocate a new buffer.
*/
if ((autobuf && !(ch_flags & CH_CANSEEK)) ||
(maxbufs < 0 || ch_nbufs < maxbufs))
if (ch_addbuf())
/*
* Allocation failed: turn off autobuf.
*/
autobuf = OPT_OFF;
if (ch_buftail == END_OF_CHAIN || ch_buftail->block != -1)
{
/*
* There is no empty buffer to use.
* Allocate a new buffer if:
* 1. We can't seek on this file and -b is not in effect; or
* 2. We haven't allocated the max buffers for this file yet.
*/
if ((autobuf && !(ch_flags & CH_CANSEEK)) ||
(maxbufs < 0 || ch_nbufs < maxbufs))
if (ch_addbuf())
/*
* Allocation failed: turn off autobuf.
*/
autobuf = OPT_OFF;
}
bp = ch_buftail;
HASH_RM(bp); /* Remove from old hash chain. */
bp->block = ch_block;
bp->datasize = 0;
HASH_INS(bp, h); /* Insert into new hash chain. */
}
bp = ch_buftail;
HASH_RM(bp); /* Remove from old hash chain. */
bp->block = ch_block;
bp->datasize = 0;
HASH_INS(bp, h); /* Insert into new hash chain. */

read_more:
pos = (ch_block * LBUFSIZE) + bp->datasize;
Expand Down
16 changes: 16 additions & 0 deletions input.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ forw_line(curr_pos)
return (NULL_POSITION);
}

/*
* Step back to the beginning of the line.
*/
base_pos = curr_pos;
for (;;)
{
Expand All @@ -95,6 +98,9 @@ forw_line(curr_pos)
--base_pos;
}

/*
* Read forward again to the position we should start at.
*/
prewind();
plinenum(base_pos);
(void) ch_seek(base_pos);
Expand All @@ -119,6 +125,9 @@ forw_line(curr_pos)
(void) pflushmbc();
pshift_all();

/*
* Read the first character to display.
*/
c = ch_forw_get();
if (c == EOI)
{
Expand All @@ -127,6 +136,9 @@ forw_line(curr_pos)
}
blankline = (c == '\n' || c == '\r');

/*
* Read each character in the line and append to the line buffer.
*/
for (;;)
{
if (ABORT_SIGS())
Expand Down Expand Up @@ -181,8 +193,12 @@ forw_line(curr_pos)
}
c = ch_forw_get();
}

pdone(endline);

if (status_col && is_hilited(base_pos, ch_tell()-1, 1, NULL))
set_status_col('*');

if (squeeze && blankline)
{
/*
Expand Down
22 changes: 10 additions & 12 deletions line.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ static int overstrike; /* Next char should overstrike previous char */
static int last_overstrike = AT_NORMAL;
static int is_null_line; /* There is no current line */
static int lmargin; /* Left margin */
static int line_matches; /* Number of search matches in this line */
static char pendc;
static POSITION pendpos;
static char *end_ansi_chars;
Expand Down Expand Up @@ -162,9 +161,6 @@ prewind()
lmargin = 0;
if (status_col)
lmargin += 1;
#if HILITE_SEARCH
line_matches = 0;
#endif
}

/*
Expand Down Expand Up @@ -592,7 +588,6 @@ store_char(ch, a, rep, pos)
if (a != AT_ANSI)
a |= AT_HILITE;
}
line_matches += matches;
}
#endif

Expand Down Expand Up @@ -1069,14 +1064,17 @@ pdone(endline)
}
linebuf[curr] = '\0';
attr[curr] = AT_NORMAL;
}

#if HILITE_SEARCH
if (status_col && line_matches > 0)
{
linebuf[0] = '*';
attr[0] = AT_NORMAL|AT_HILITE;
}
#endif
/*
*
*/
public void
set_status_col(c)
char c;
{
linebuf[0] = c;
attr[0] = AT_NORMAL|AT_HILITE;
}

/*
Expand Down

0 comments on commit 103b80c

Please sign in to comment.