version 1.13, 2015/12/25 14:29:22 |
version 1.14, 2016/01/12 17:48:04 |
|
|
struct linenum_info *prev; /* Line to previous in the list */ |
struct linenum_info *prev; /* Line to previous in the list */ |
off_t pos; /* File position */ |
off_t pos; /* File position */ |
off_t gap; /* Gap between prev and next */ |
off_t gap; /* Gap between prev and next */ |
LINENUM line; /* Line number */ |
off_t line; /* Line number */ |
}; |
}; |
/* |
/* |
* "gap" needs some explanation: the gap of any particular line number |
* "gap" needs some explanation: the gap of any particular line number |
|
|
* FIRST character in the specified line. |
* FIRST character in the specified line. |
*/ |
*/ |
void |
void |
add_lnum(LINENUM linenum, off_t pos) |
add_lnum(off_t linenum, off_t pos) |
{ |
{ |
struct linenum_info *p; |
struct linenum_info *p; |
struct linenum_info *new; |
struct linenum_info *new; |
|
|
static void |
static void |
longish(void) |
longish(void) |
{ |
{ |
if (loopcount >= 0 && ++loopcount > 100) { |
if (++loopcount > 100) { |
loopcount = 0; |
loopcount = 0; |
if (time(NULL) >= startime + LONGTIME) { |
if (time(NULL) >= startime + LONGTIME) { |
ierror("Calculating line numbers", NULL); |
ierror("Calculating line numbers", NULL); |
|
|
* Find the line number associated with a given position. |
* Find the line number associated with a given position. |
* Return 0 if we can't figure it out. |
* Return 0 if we can't figure it out. |
*/ |
*/ |
LINENUM |
off_t |
find_linenum(off_t pos) |
find_linenum(off_t pos) |
{ |
{ |
struct linenum_info *p; |
struct linenum_info *p; |
LINENUM linenum; |
off_t linenum; |
off_t cpos; |
off_t cpos; |
|
|
if (!linenums) |
if (!linenums) |
|
|
* Return -1 if we can't figure it out. |
* Return -1 if we can't figure it out. |
*/ |
*/ |
off_t |
off_t |
find_pos(LINENUM linenum) |
find_pos(off_t linenum) |
{ |
{ |
struct linenum_info *p; |
struct linenum_info *p; |
off_t cpos; |
off_t cpos; |
LINENUM clinenum; |
off_t clinenum; |
|
|
if (linenum <= 1) |
if (linenum <= 1) |
/* |
/* |
|
|
* The argument "where" tells which line is to be considered |
* The argument "where" tells which line is to be considered |
* the "current" line (e.g. TOP, BOTTOM, MIDDLE, etc). |
* the "current" line (e.g. TOP, BOTTOM, MIDDLE, etc). |
*/ |
*/ |
LINENUM |
off_t |
currline(int where) |
currline(int where) |
{ |
{ |
off_t pos; |
off_t pos; |
off_t len; |
off_t len; |
LINENUM linenum; |
off_t linenum; |
|
|
pos = position(where); |
pos = position(where); |
len = ch_length(); |
len = ch_length(); |