Fix tiny build. Rename things to hopefully be more fitting
This commit is contained in:
parent
b145ce016b
commit
49935c0456
26
src/cut.c
26
src/cut.c
@ -48,7 +48,7 @@ void do_deletion(undo_type action)
|
||||
memmove(&openfile->current->data[openfile->current_x],
|
||||
&openfile->current->data[openfile->current_x + charlen],
|
||||
line_len - charlen + 1);
|
||||
UNFOLD_IF_FOLDED(openfile->current);
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
#ifndef NANO_TINY
|
||||
/* When softwrapping, a changed number of chunks requires a refresh. */
|
||||
if (ISSET(SOFTWRAP) && extra_chunks_in(openfile->current) != old_amount)
|
||||
@ -63,8 +63,8 @@ void do_deletion(undo_type action)
|
||||
} else if (openfile->current != openfile->filebot) {
|
||||
linestruct *joining = openfile->current->next;
|
||||
|
||||
UNFOLD_IF_FOLDED(openfile->current);
|
||||
UNFOLD_IF_FOLDED(joining);
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
UNFOLD_SEGMENT(joining);
|
||||
|
||||
/* If there is a magic line, and we're before it: don't eat it. */
|
||||
if (joining == openfile->filebot && openfile->current_x != 0 &&
|
||||
@ -206,7 +206,7 @@ void chop_word(bool forward)
|
||||
openfile->current_x = strlen(is_current->data);
|
||||
}
|
||||
}
|
||||
UNFOLD_IF_FOLDED(openfile->current);
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
|
||||
/* Set the mark at the start of that word. */
|
||||
openfile->mark = openfile->current;
|
||||
@ -258,16 +258,14 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
|
||||
static bool inherited_anchor = FALSE;
|
||||
bool had_anchor = top->has_anchor;
|
||||
|
||||
UNFOLD_IF_FOLDED(top);
|
||||
|
||||
if (top == bot && top_x == bot_x)
|
||||
return;
|
||||
|
||||
UNFOLD_SEGMENT(top);
|
||||
|
||||
if (top != bot)
|
||||
for (linestruct *line = top->next; line != bot->next; line = line->next) {
|
||||
for (linestruct *line = top->next; line != bot->next; line = line->next)
|
||||
had_anchor |= line->has_anchor;
|
||||
UNFOLD_IF_FOLDED(line);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (top == bot) {
|
||||
@ -276,6 +274,7 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
|
||||
memmove(top->data + top_x, top->data + bot_x, strlen(top->data + bot_x) + 1);
|
||||
last = taken;
|
||||
} else if (top_x == 0 && bot_x == 0) {
|
||||
UNFOLD_SEGMENT(bot);
|
||||
taken = top;
|
||||
last = make_new_node(NULL);
|
||||
last->data = copy_of("");
|
||||
@ -289,13 +288,12 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
|
||||
bot->prev = top->prev;
|
||||
if (top->prev)
|
||||
top->prev->next = bot;
|
||||
else {
|
||||
else
|
||||
openfile->filetop = bot;
|
||||
UNFOLD_IF_FOLDED(openfile->filetop);
|
||||
}
|
||||
|
||||
openfile->current = bot;
|
||||
} else {
|
||||
UNFOLD_SEGMENT(bot);
|
||||
taken = make_new_node(NULL);
|
||||
taken->data = copy_of(top->data + top_x);
|
||||
taken->next = top->next;
|
||||
@ -383,7 +381,7 @@ void ingraft_buffer(linestruct *topline)
|
||||
#endif
|
||||
linestruct *botline = topline;
|
||||
|
||||
UNFOLD_IF_FOLDED(line);
|
||||
UNFOLD_SEGMENT(line);
|
||||
|
||||
while (botline->next != NULL)
|
||||
botline = botline->next;
|
||||
@ -735,7 +733,7 @@ void paste_text(void)
|
||||
statusline(AHEM, _("Cutbuffer is empty"));
|
||||
return;
|
||||
}
|
||||
UNFOLD_IF_FOLDED(openfile->current);
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(PASTE, NULL);
|
||||
|
||||
@ -266,9 +266,9 @@
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FOLDING
|
||||
#define UNFOLD_IF_FOLDED(line) unfold_folded_segment(line)
|
||||
#define UNFOLD_SEGMENT(line) unfold_folded_segment(line)
|
||||
#else
|
||||
#define UNFOLD_IF_FOLDED(line)
|
||||
#define UNFOLD_SEGMENT(line)
|
||||
#endif
|
||||
|
||||
#define ALLOW_FOLDED TRUE
|
||||
|
||||
@ -680,7 +680,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||
if (ISSET(SOFTWRAP))
|
||||
was_leftedge = leftedge_for(xplustabs(), openfile->current);
|
||||
#endif
|
||||
UNFOLD_IF_FOLDED(openfile->current);
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
|
||||
/* Create an empty buffer. */
|
||||
topline = make_new_node(NULL);
|
||||
|
||||
@ -27,15 +27,19 @@
|
||||
|
||||
#ifdef ENABLE_FOLDING
|
||||
|
||||
/* Remove a folded segment from the given line until end of segment */
|
||||
void unfold_folded_segment_from(linestruct *line)
|
||||
{
|
||||
if (line != NULL)
|
||||
refresh_needed = TRUE;
|
||||
for(;line != NULL && line->folded;line = line->next)
|
||||
line->folded = FALSE;
|
||||
}
|
||||
|
||||
/* Remove a folded segment containing the given line */
|
||||
void unfold_folded_segment(linestruct *line)
|
||||
{
|
||||
line = get_start_of_folded_segment(line);
|
||||
if (line != NULL)
|
||||
refresh_needed = TRUE;
|
||||
|
||||
for (;line != NULL && line->folded;line = line->next)
|
||||
line->folded = FALSE;
|
||||
unfold_folded_segment_from(get_start_of_folded_segment(line));
|
||||
}
|
||||
|
||||
/* Get the first member of the folded segment */
|
||||
|
||||
12
src/move.c
12
src/move.c
@ -36,16 +36,14 @@ void to_first_line(void)
|
||||
/* Move to the last line of the file. */
|
||||
void to_last_line(void)
|
||||
{
|
||||
openfile->current = openfile->filebot;
|
||||
#ifdef ENABLE_FOLDING
|
||||
if (openfile->filebot->folded) {
|
||||
openfile->current = get_start_of_folded_segment(openfile->filebot);
|
||||
if (openfile->current->folded) {
|
||||
openfile->current = get_start_of_folded_segment(openfile->current);
|
||||
openfile->current_x = 0;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
openfile->current = openfile->filebot;
|
||||
openfile->current_x = (inhelp) ? 0 : strlen(openfile->filebot->data);
|
||||
}
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
/* Set the last line of the screen as the target for the cursor. */
|
||||
@ -362,7 +360,7 @@ void do_prev_word(bool allow_folded)
|
||||
/* Move one character forward again to sit on the start of the word. */
|
||||
openfile->current_x = step_right(openfile->current->data,
|
||||
openfile->current_x);
|
||||
UNFOLD_IF_FOLDED(openfile->current);
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
}
|
||||
|
||||
/* Move to the next word. If after_ends is TRUE, stop at the ends of words
|
||||
@ -442,7 +440,7 @@ bool do_next_word(bool after_ends, bool allow_folded)
|
||||
}
|
||||
}
|
||||
|
||||
UNFOLD_IF_FOLDED(openfile->current);
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
|
||||
return started_on_word;
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ void delete_node(linestruct *line)
|
||||
/* Disconnect a node from a linked list of linestructs and delete it. */
|
||||
void unlink_node(linestruct *line)
|
||||
{
|
||||
UNFOLD_IF_FOLDED(line);
|
||||
UNFOLD_SEGMENT(line);
|
||||
if (line->prev != NULL)
|
||||
line->prev->next = line->next;
|
||||
if (line->next != NULL)
|
||||
@ -1429,7 +1429,7 @@ void inject(char *burst, size_t count)
|
||||
#ifndef NANO_TINY
|
||||
size_t original_row = 0;
|
||||
size_t old_amount = 0;
|
||||
UNFOLD_IF_FOLDED(thisline);
|
||||
UNFOLD_SEGMENT(thisline);
|
||||
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
if (openfile->current_y == editwinrows - 1)
|
||||
|
||||
@ -673,6 +673,7 @@ void do_cancel(void);
|
||||
#ifdef ENABLE_FOLDING
|
||||
void do_fold_segment(void);
|
||||
void unfold_folded_segment(linestruct *line);
|
||||
void unfold_folded_segment_from(linestruct *line);
|
||||
void unfold_if_folded(linestruct* line);
|
||||
linestruct *get_start_of_folded_segment(linestruct* line);
|
||||
linestruct *get_end_of_folded_segment(linestruct* line);
|
||||
|
||||
10
src/search.c
10
src/search.c
@ -307,7 +307,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
|
||||
}
|
||||
}
|
||||
|
||||
UNFOLD_IF_FOLDED(line);
|
||||
UNFOLD_SEGMENT(line);
|
||||
|
||||
found_x = found - line->data;
|
||||
|
||||
@ -753,7 +753,7 @@ void goto_line_posx(ssize_t line, size_t pos_x)
|
||||
|
||||
openfile->current_x = pos_x;
|
||||
openfile->placewewant = xplustabs();
|
||||
UNFOLD_IF_FOLDED(openfile->current);
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
@ -824,7 +824,7 @@ void goto_line_and_column(ssize_t line, ssize_t column, bool retain_answer,
|
||||
openfile->current != openfile->filebot; line--)
|
||||
openfile->current = openfile->current->next;
|
||||
|
||||
UNFOLD_IF_FOLDED(openfile->current);
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
|
||||
/* Take a negative column number to mean: from the end of the line. */
|
||||
if (column < 0)
|
||||
@ -1112,7 +1112,7 @@ void do_find_bracket(void)
|
||||
int res = find_matching_bracket_pos(&openfile->current,
|
||||
&openfile->current_x);
|
||||
if (res == FOUND_BRACKET) {
|
||||
UNFOLD_IF_FOLDED(openfile->current);
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
edit_redraw(was_current, FLOWING);
|
||||
return;
|
||||
}
|
||||
@ -1146,7 +1146,7 @@ void go_to_and_confirm(linestruct *line)
|
||||
if (line != openfile->current) {
|
||||
openfile->current = line;
|
||||
openfile->current_x = 0;
|
||||
UNFOLD_IF_FOLDED(openfile->current);
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
#ifdef ENABLE_COLOR
|
||||
if (line->lineno > openfile->edittop->lineno + editwinrows ||
|
||||
(ISSET(SOFTWRAP) && line->lineno > was_current->lineno))
|
||||
|
||||
18
src/text.c
18
src/text.c
@ -96,7 +96,7 @@ void indent_a_line(linestruct *line, char *indentation)
|
||||
if (indent_len == 0)
|
||||
return;
|
||||
|
||||
UNFOLD_IF_FOLDED(line);
|
||||
UNFOLD_SEGMENT(line);
|
||||
|
||||
/* Add the fabricated indentation to the beginning of the line. */
|
||||
line->data = nrealloc(line->data, length + indent_len + 1);
|
||||
@ -228,7 +228,7 @@ void unindent_a_line(linestruct *line, size_t indent_len)
|
||||
if (indent_len == 0)
|
||||
return;
|
||||
|
||||
UNFOLD_IF_FOLDED(line);
|
||||
UNFOLD_SEGMENT(line);
|
||||
|
||||
/* Remove the first tab's worth of whitespace from this line. */
|
||||
memmove(line->data, line->data + indent_len, length - indent_len + 1);
|
||||
@ -321,7 +321,7 @@ bool comment_line(undo_type action, linestruct *line, const char *comment_seq)
|
||||
/* Length of postfix. */
|
||||
size_t line_len = strlen(line->data);
|
||||
|
||||
UNFOLD_IF_FOLDED(line);
|
||||
UNFOLD_SEGMENT(line);
|
||||
|
||||
if (!ISSET(NO_NEWLINES) && line == openfile->filebot)
|
||||
return FALSE;
|
||||
@ -423,7 +423,6 @@ void do_comment(void)
|
||||
* store undo data when a line changed. */
|
||||
for (line = top; line != bot->next; line = line->next)
|
||||
if (comment_line(action, line, comment_seq)) {
|
||||
UNFOLD_IF_FOLDED(line);
|
||||
update_multiline_undo(line->lineno, "");
|
||||
}
|
||||
|
||||
@ -863,7 +862,12 @@ void do_enter(void)
|
||||
linestruct *newnode = make_new_node(openfile->current);
|
||||
size_t extra = 0;
|
||||
|
||||
UNFOLD_IF_FOLDED(openfile->current);
|
||||
#ifdef ENABLE_FOLDING
|
||||
if (openfile->current->folded) {
|
||||
newnode->folded = TRUE;
|
||||
openfile->current->folded = FALSE;
|
||||
}
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
linestruct *sampleline = openfile->current;
|
||||
bool allblanks = FALSE;
|
||||
@ -1590,7 +1594,7 @@ void concat_paragraph(linestruct *line, size_t count)
|
||||
line->data = nrealloc(line->data,
|
||||
line_len + next_line_len - next_lead_len + 1);
|
||||
strcat(line->data, next_line->data + next_lead_len);
|
||||
UNFOLD_IF_FOLDED(line);
|
||||
UNFOLD_SEGMENT(line);
|
||||
#ifndef NANO_TINY
|
||||
line->has_anchor |= next_line->has_anchor;
|
||||
#endif
|
||||
@ -2849,7 +2853,7 @@ void do_linter(void)
|
||||
|
||||
/* Place the cursor to indicate the affected line. */
|
||||
place_the_cursor();
|
||||
UNFOLD_IF_FOLDED(openfile->current);
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
wnoutrefresh(midwin);
|
||||
|
||||
kbinput = get_kbinput(footwin, VISIBLE);
|
||||
|
||||
102
src/winio.c
102
src/winio.c
@ -74,55 +74,6 @@ static int *macro_buffer = NULL;
|
||||
static size_t macro_length = 0;
|
||||
/* The current length of the macro. */
|
||||
|
||||
/* Return the current offset of target from openfile->edittop */
|
||||
int get_row_from_edittop(linestruct *target)
|
||||
{
|
||||
#ifdef ENABLE_FOLDING
|
||||
linestruct *line = openfile->edittop;
|
||||
int row = 0;
|
||||
while (line != NULL && line != target && row < editwinrows) {
|
||||
line = get_end_of_folded_segment(line);
|
||||
line = line->next;
|
||||
++row;
|
||||
}
|
||||
return row;
|
||||
#else
|
||||
return target->lineno - openfile->edittop->lineno;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Return the next line, taking fold segments into account */
|
||||
linestruct *get_next_visible_line(linestruct *line)
|
||||
{
|
||||
if (!line)
|
||||
return NULL;
|
||||
|
||||
#ifdef ENABLE_FOLDING
|
||||
line = get_end_of_folded_segment(line);
|
||||
if (line == NULL)
|
||||
return NULL;
|
||||
#endif
|
||||
return line->next;
|
||||
}
|
||||
|
||||
/* Return the previous line, taking fold segments into account */
|
||||
linestruct *get_prev_visible_line(linestruct *line)
|
||||
{
|
||||
if (!line)
|
||||
return NULL;
|
||||
|
||||
#ifdef ENABLE_FOLDING
|
||||
if (line->folded) {
|
||||
line = get_start_of_folded_segment(line);
|
||||
return line == NULL ? NULL : line->prev;
|
||||
}
|
||||
if (line->prev != NULL && line->prev->folded)
|
||||
return get_start_of_folded_segment(line->prev);
|
||||
|
||||
#endif
|
||||
return line->prev;
|
||||
}
|
||||
|
||||
/* Add the given code to the macro buffer. */
|
||||
void add_to_macrobuffer(int code)
|
||||
{
|
||||
@ -182,6 +133,55 @@ void run_macro(void)
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Return the current offset of target from openfile->edittop */
|
||||
int get_row_from_edittop(linestruct *target)
|
||||
{
|
||||
#ifdef ENABLE_FOLDING
|
||||
linestruct *line = openfile->edittop;
|
||||
int row = 0;
|
||||
while (line != NULL && line != target && row < editwinrows) {
|
||||
line = get_end_of_folded_segment(line);
|
||||
line = line->next;
|
||||
++row;
|
||||
}
|
||||
return row;
|
||||
#else
|
||||
return target->lineno - openfile->edittop->lineno;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Return the next line, taking fold segments into account */
|
||||
linestruct *get_next_visible_line(linestruct *line)
|
||||
{
|
||||
if (!line)
|
||||
return NULL;
|
||||
|
||||
#ifdef ENABLE_FOLDING
|
||||
line = get_end_of_folded_segment(line);
|
||||
if (line == NULL)
|
||||
return NULL;
|
||||
#endif
|
||||
return line->next;
|
||||
}
|
||||
|
||||
/* Return the previous line, taking fold segments into account */
|
||||
linestruct *get_prev_visible_line(linestruct *line)
|
||||
{
|
||||
if (!line)
|
||||
return NULL;
|
||||
|
||||
#ifdef ENABLE_FOLDING
|
||||
if (line->folded) {
|
||||
line = get_start_of_folded_segment(line);
|
||||
return line == NULL ? NULL : line->prev;
|
||||
}
|
||||
if (line->prev != NULL && line->prev->folded)
|
||||
return get_start_of_folded_segment(line->prev);
|
||||
|
||||
#endif
|
||||
return line->prev;
|
||||
}
|
||||
|
||||
/* Control character compatibility:
|
||||
*
|
||||
* - Ctrl-H is Backspace under ASCII, ANSI, VT100, and VT220.
|
||||
@ -3439,9 +3439,9 @@ bool current_is_below_screen(void)
|
||||
(line->lineno < openfile->current->lineno ||
|
||||
(line->lineno == openfile->current->lineno &&
|
||||
leftedge < leftedge_for(xplustabs(), openfile->current))));
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
return (get_row_from_edittop(openfile->current) >= editwinrows - SHIM);
|
||||
return (get_row_from_edittop(openfile->current) >= editwinrows - SHIM);
|
||||
}
|
||||
|
||||
/* Return TRUE if current[current_x] is outside the viewport. */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user