summaryrefslogtreecommitdiffstats
path: root/usr.bin/ee
diff options
context:
space:
mode:
authorsobomax <sobomax@FreeBSD.org>2000-08-21 10:21:28 +0000
committersobomax <sobomax@FreeBSD.org>2000-08-21 10:21:28 +0000
commit3d0106e334c50bd3a7135c144640a2c380eae578 (patch)
treeec00ad3e25b76b2f30b6be8beeadd02e0d27f2d6 /usr.bin/ee
parentac0a5daf19d44a9b233f200b06a4b4bfd0ad4a88 (diff)
downloadFreeBSD-src-3d0106e334c50bd3a7135c144640a2c380eae578.zip
FreeBSD-src-3d0106e334c50bd3a7135c144640a2c380eae578.tar.gz
Fix a bug introduced by my own previous commit (addition of the current
line/column display). I overlooked that ee(1) doesn't maintain proper line numbering when adding/removing lines, so after those operations linenumber displayed may not match the reality. Also use proper variable for current column diaplay, because the one used previously reflects the offset of current char, which doesn't equial screen position when tabs present. Reviewed by: bp
Diffstat (limited to 'usr.bin/ee')
-rw-r--r--usr.bin/ee/ee.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/usr.bin/ee/ee.c b/usr.bin/ee/ee.c
index 609ee6a..88a89e1 100644
--- a/usr.bin/ee/ee.c
+++ b/usr.bin/ee/ee.c
@@ -338,6 +338,7 @@ char *is_in_string P_((char *string, char *substring));
char *resolve_name P_((char *name));
int restrict_mode P_((void));
int unique_test P_((char *string, char *list[]));
+void renumber_lines P_((struct text *firstline, int startnumber));
void strings_init P_((void));
#undef P_
@@ -610,7 +611,7 @@ char *argv[];
if (info_window)
{
snprintf(count_text, count_text_len, "L: %d C: %d %s", \
- curr_line->line_number, position, count_text_default);
+ curr_line->line_number, scr_horz + 1, count_text_default);
wmove(count_win, 0, 0);
wclrtoeol(count_win);
if (!nohighlight)
@@ -804,6 +805,7 @@ int disp;
if (temp_buff->next_line != NULL)
temp_buff->next_line->prev_line = curr_line;
curr_line->next_line = temp_buff->next_line;
+ renumber_lines(curr_line->next_line, curr_line->line_number + 1);
temp2 = temp_buff->line;
if (in == 8)
d_char = '\n';
@@ -1045,8 +1047,8 @@ int disp;
temp_nod->line = extra= malloc(10);
temp_nod->line_length = 1;
temp_nod->max_length = 10;
- temp_nod->line_number = curr_line->line_number + 1;
temp_nod->next_line = curr_line->next_line;
+ renumber_lines(temp_nod, curr_line->line_number + 1);
if (temp_nod->next_line != NULL)
temp_nod->next_line->prev_line = temp_nod;
temp_nod->prev_line = curr_line;
@@ -2256,8 +2258,8 @@ int *append; /* TRUE if must append more text to end of current line */
if (!(*append)) /* if not append to current line, insert new one */
{
tline = txtalloc(); /* allocate data structure for next line */
- tline->line_number = curr_line->line_number + 1;
tline->next_line = curr_line->next_line;
+ renumber_lines(tline, curr_line->line_number + 1);
tline->prev_line = curr_line;
curr_line->next_line = tline;
if (tline->next_line != NULL)
@@ -4845,6 +4847,19 @@ char *list[];
return(num_match);
}
+void
+renumber_lines(firstline, startnumber)
+struct text *firstline;
+int startnumber;
+{
+ struct text *lineptr;
+ int i;
+
+ i = startnumber;
+ for (lineptr = firstline; lineptr != NULL; lineptr = lineptr->next_line)
+ lineptr->line_number = i++;
+}
+
#ifndef NO_CATGETS
/*
| Get the catalog entry, and if it got it from the catalog,
OpenPOWER on IntegriCloud