version 1.4, 2003/04/13 18:26:26 |
version 1.5, 2011/09/16 18:12:09 |
|
|
/* |
/* |
* Copyright (C) 1984-2002 Mark Nudelman |
* Copyright (C) 1984-2011 Mark Nudelman |
* |
* |
* You may distribute under the terms of either the GNU General Public |
* You may distribute under the terms of either the GNU General Public |
* License or the Less License, as specified in the README file. |
* License or the Less License, as specified in the README file. |
|
|
* when we have a new one to insert and the table is full. |
* when we have a new one to insert and the table is full. |
*/ |
*/ |
|
|
#define NPOOL 50 /* Size of line number pool */ |
#define NPOOL 200 /* Size of line number pool */ |
|
|
#define LONGTIME (2) /* In seconds */ |
#define LONGTIME (2) /* In seconds */ |
|
|
public int lnloop = 0; /* Are we in the line num loop? */ |
|
|
|
static struct linenum_info anchor; /* Anchor of the list */ |
static struct linenum_info anchor; /* Anchor of the list */ |
static struct linenum_info *freelist; /* Anchor of the unused entries */ |
static struct linenum_info *freelist; /* Anchor of the unused entries */ |
static struct linenum_info pool[NPOOL]; /* The pool itself */ |
static struct linenum_info pool[NPOOL]; /* The pool itself */ |
|
|
extern int linenums; |
extern int linenums; |
extern int sigs; |
extern int sigs; |
extern int sc_height; |
extern int sc_height; |
|
extern int screen_trashed; |
|
|
/* |
/* |
* Initialize the line number structures. |
* Initialize the line number structures. |
|
|
longloopmessage() |
longloopmessage() |
{ |
{ |
ierror("Calculating line numbers", NULL_PARG); |
ierror("Calculating line numbers", NULL_PARG); |
/* |
|
* Set the lnloop flag here, so if the user interrupts while |
|
* we are calculating line numbers, the signal handler will |
|
* turn off line numbers (linenums=0). |
|
*/ |
|
lnloop = 1; |
|
} |
} |
|
|
static int loopcount; |
static int loopcount; |
|
|
} |
} |
|
|
/* |
/* |
|
* Turn off line numbers because the user has interrupted |
|
* a lengthy line number calculation. |
|
*/ |
|
static void |
|
abort_long() |
|
{ |
|
if (linenums == OPT_ONPLUS) |
|
/* |
|
* We were displaying line numbers, so need to repaint. |
|
*/ |
|
screen_trashed = 1; |
|
linenums = 0; |
|
error("Line numbers turned off", NULL_PARG); |
|
} |
|
|
|
/* |
* 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. |
*/ |
*/ |
|
|
/* |
/* |
* Allow a signal to abort this loop. |
* Allow a signal to abort this loop. |
*/ |
*/ |
cpos = forw_raw_line(cpos, (char **)NULL); |
cpos = forw_raw_line(cpos, (char **)NULL, (int *)NULL); |
if (ABORT_SIGS() || cpos == NULL_POSITION) |
if (ABORT_SIGS()) { |
|
abort_long(); |
return (0); |
return (0); |
|
} |
|
if (cpos == NULL_POSITION) |
|
return (0); |
longish(); |
longish(); |
} |
} |
lnloop = 0; |
|
/* |
/* |
* We might as well cache it. |
* We might as well cache it. |
*/ |
*/ |
|
|
/* |
/* |
* Allow a signal to abort this loop. |
* Allow a signal to abort this loop. |
*/ |
*/ |
cpos = back_raw_line(cpos, (char **)NULL); |
cpos = back_raw_line(cpos, (char **)NULL, (int *)NULL); |
if (ABORT_SIGS() || cpos == NULL_POSITION) |
if (ABORT_SIGS()) { |
|
abort_long(); |
return (0); |
return (0); |
|
} |
|
if (cpos == NULL_POSITION) |
|
return (0); |
longish(); |
longish(); |
} |
} |
lnloop = 0; |
|
/* |
/* |
* We might as well cache it. |
* We might as well cache it. |
*/ |
*/ |
|
|
/* |
/* |
* Allow a signal to abort this loop. |
* Allow a signal to abort this loop. |
*/ |
*/ |
cpos = forw_raw_line(cpos, (char **)NULL); |
cpos = forw_raw_line(cpos, (char **)NULL, (int *)NULL); |
if (ABORT_SIGS() || cpos == NULL_POSITION) |
if (ABORT_SIGS()) |
return (NULL_POSITION); |
return (NULL_POSITION); |
|
if (cpos == NULL_POSITION) |
|
return (NULL_POSITION); |
} |
} |
} else |
} else |
{ |
{ |
|
|
/* |
/* |
* Allow a signal to abort this loop. |
* Allow a signal to abort this loop. |
*/ |
*/ |
cpos = back_raw_line(cpos, (char **)NULL); |
cpos = back_raw_line(cpos, (char **)NULL, (int *)NULL); |
if (ABORT_SIGS() || cpos == NULL_POSITION) |
if (ABORT_SIGS()) |
|
return (NULL_POSITION); |
|
if (cpos == NULL_POSITION) |
return (NULL_POSITION); |
return (NULL_POSITION); |
} |
} |
} |
} |