mirror of git://git.sv.gnu.org/nano.git
tweaks: get rid of a bunch of annoying casts, and thus condense the code
This commit is contained in:
parent
8f6559828d
commit
59040169ed
|
@ -434,8 +434,7 @@ void cut_marked_region(void)
|
||||||
linestruct *top, *bot;
|
linestruct *top, *bot;
|
||||||
size_t top_x, bot_x;
|
size_t top_x, bot_x;
|
||||||
|
|
||||||
get_region((const linestruct **)&top, &top_x,
|
get_region(&top, &top_x, &bot, &bot_x);
|
||||||
(const linestruct **)&bot, &bot_x);
|
|
||||||
|
|
||||||
extract_segment(top, top_x, bot, bot_x);
|
extract_segment(top, top_x, bot, bot_x);
|
||||||
|
|
||||||
|
|
|
@ -2026,8 +2026,7 @@ bool write_marked_file(const char *name, FILE *stream, bool tmp,
|
||||||
size_t top_x, bot_x;
|
size_t top_x, bot_x;
|
||||||
|
|
||||||
/* Partition the buffer so that it contains only the marked text. */
|
/* Partition the buffer so that it contains only the marked text. */
|
||||||
get_region((const linestruct **)&top, &top_x,
|
get_region(&top, &top_x, &bot, &bot_x);
|
||||||
(const linestruct **)&bot, &bot_x);
|
|
||||||
partition_buffer(top, top_x, bot, bot_x);
|
partition_buffer(top, top_x, bot, bot_x);
|
||||||
|
|
||||||
/* If we are using a magic line, and the last line of the partition
|
/* If we are using a magic line, and the last line of the partition
|
||||||
|
|
|
@ -573,9 +573,8 @@ void remove_magicline(void);
|
||||||
#endif
|
#endif
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
bool mark_is_before_cursor(void);
|
bool mark_is_before_cursor(void);
|
||||||
void get_region(const linestruct **top, size_t *top_x,
|
void get_region(linestruct **top, size_t *top_x, linestruct **bot, size_t *bot_x);
|
||||||
const linestruct **bot, size_t *bot_x);
|
void get_range(linestruct **top, linestruct **bot);
|
||||||
void get_range(const linestruct **top, const linestruct **bot);
|
|
||||||
#endif
|
#endif
|
||||||
size_t get_totsize(const linestruct *begin, const linestruct *end);
|
size_t get_totsize(const linestruct *begin, const linestruct *end);
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
|
|
|
@ -522,8 +522,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||||
|
|
||||||
/* If the mark is on, frame the region, and turn the mark off. */
|
/* If the mark is on, frame the region, and turn the mark off. */
|
||||||
if (openfile->mark) {
|
if (openfile->mark) {
|
||||||
get_region((const linestruct **)&top, &top_x,
|
get_region(&top, &top_x, &bot, &bot_x);
|
||||||
(const linestruct **)&bot, &bot_x);
|
|
||||||
openfile->mark = NULL;
|
openfile->mark = NULL;
|
||||||
modus = INREGION;
|
modus = INREGION;
|
||||||
|
|
||||||
|
|
15
src/text.c
15
src/text.c
|
@ -120,7 +120,7 @@ void do_indent(void)
|
||||||
linestruct *top, *bot, *line;
|
linestruct *top, *bot, *line;
|
||||||
|
|
||||||
/* Use either all the marked lines or just the current line. */
|
/* Use either all the marked lines or just the current line. */
|
||||||
get_range((const linestruct **)&top, (const linestruct **)&bot);
|
get_range(&top, &bot);
|
||||||
|
|
||||||
/* Skip any leading empty lines. */
|
/* Skip any leading empty lines. */
|
||||||
while (top != bot->next && top->data[0] == '\0')
|
while (top != bot->next && top->data[0] == '\0')
|
||||||
|
@ -241,7 +241,7 @@ void do_unindent(void)
|
||||||
linestruct *top, *bot, *line;
|
linestruct *top, *bot, *line;
|
||||||
|
|
||||||
/* Use either all the marked lines or just the current line. */
|
/* Use either all the marked lines or just the current line. */
|
||||||
get_range((const linestruct **)&top, (const linestruct **)&bot);
|
get_range(&top, &bot);
|
||||||
|
|
||||||
/* Skip any leading lines that cannot be unindented. */
|
/* Skip any leading lines that cannot be unindented. */
|
||||||
while (top != bot->next && length_of_white(top->data) == 0)
|
while (top != bot->next && length_of_white(top->data) == 0)
|
||||||
|
@ -386,7 +386,7 @@ void do_comment(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Determine which lines to work on. */
|
/* Determine which lines to work on. */
|
||||||
get_range((const linestruct **)&top, (const linestruct **)&bot);
|
get_range(&top, &bot);
|
||||||
|
|
||||||
/* If only the magic line is selected, don't do anything. */
|
/* If only the magic line is selected, don't do anything. */
|
||||||
if (top == bot && bot == openfile->filebot && !ISSET(NO_NEWLINES)) {
|
if (top == bot && bot == openfile->filebot && !ISSET(NO_NEWLINES)) {
|
||||||
|
@ -1744,8 +1744,7 @@ void do_justify(bool full_justify)
|
||||||
size_t quot_len, fore_len, other_quot_len, other_white_len;
|
size_t quot_len, fore_len, other_quot_len, other_white_len;
|
||||||
linestruct *sampleline;
|
linestruct *sampleline;
|
||||||
|
|
||||||
get_region((const linestruct **)&startline, &start_x,
|
get_region(&startline, &start_x, &endline, &end_x);
|
||||||
(const linestruct **)&endline, &end_x);
|
|
||||||
|
|
||||||
/* When the marked region is empty, do nothing. */
|
/* When the marked region is empty, do nothing. */
|
||||||
if (startline == endline && start_x == end_x) {
|
if (startline == endline && start_x == end_x) {
|
||||||
|
@ -2034,8 +2033,7 @@ bool fix_spello(const char *word)
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
/* If the mark is on, start at the beginning of the marked region. */
|
/* If the mark is on, start at the beginning of the marked region. */
|
||||||
if (openfile->mark) {
|
if (openfile->mark) {
|
||||||
get_region((const linestruct **)&top, &top_x,
|
get_region(&top, &top_x, &bot, &bot_x);
|
||||||
(const linestruct **)&bot, &bot_x);
|
|
||||||
/* If the region is marked normally, swap the end points, so that
|
/* If the region is marked normally, swap the end points, so that
|
||||||
* (current, current_x) (where searching starts) is at the top. */
|
* (current, current_x) (where searching starts) is at the top. */
|
||||||
if (right_side_up) {
|
if (right_side_up) {
|
||||||
|
@ -2913,8 +2911,7 @@ void do_wordlinechar_count(void)
|
||||||
/* If the mark is on, partition the buffer so that it
|
/* If the mark is on, partition the buffer so that it
|
||||||
* contains only the marked text, and turn the mark off. */
|
* contains only the marked text, and turn the mark off. */
|
||||||
if (openfile->mark) {
|
if (openfile->mark) {
|
||||||
get_region((const linestruct **)&top, &top_x,
|
get_region(&top, &top_x, &bot, &bot_x);
|
||||||
(const linestruct **)&bot, &bot_x);
|
|
||||||
partition_buffer(top, top_x, bot, bot_x);
|
partition_buffer(top, top_x, bot, bot_x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -460,8 +460,7 @@ bool mark_is_before_cursor(void)
|
||||||
|
|
||||||
/* Return in (top, top_x) and (bot, bot_x) the start and end "coordinates"
|
/* Return in (top, top_x) and (bot, bot_x) the start and end "coordinates"
|
||||||
* of the marked region. */
|
* of the marked region. */
|
||||||
void get_region(const linestruct **top, size_t *top_x,
|
void get_region(linestruct **top, size_t *top_x, linestruct **bot, size_t *bot_x)
|
||||||
const linestruct **bot, size_t *bot_x)
|
|
||||||
{
|
{
|
||||||
if (mark_is_before_cursor()) {
|
if (mark_is_before_cursor()) {
|
||||||
*top = openfile->mark;
|
*top = openfile->mark;
|
||||||
|
@ -479,7 +478,7 @@ void get_region(const linestruct **top, size_t *top_x,
|
||||||
/* Get the set of lines to work on -- either just the current line, or the
|
/* Get the set of lines to work on -- either just the current line, or the
|
||||||
* first to last lines of the marked region. When the cursor (or mark) is
|
* first to last lines of the marked region. When the cursor (or mark) is
|
||||||
* at the start of the last line of the region, exclude that line. */
|
* at the start of the last line of the region, exclude that line. */
|
||||||
void get_range(const linestruct **top, const linestruct **bot)
|
void get_range(linestruct **top, linestruct **bot)
|
||||||
{
|
{
|
||||||
if (!openfile->mark) {
|
if (!openfile->mark) {
|
||||||
*top = openfile->current;
|
*top = openfile->current;
|
||||||
|
|
|
@ -2677,7 +2677,7 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||||
line->lineno <= openfile->current->lineno) ||
|
line->lineno <= openfile->current->lineno) ||
|
||||||
(line->lineno <= openfile->mark->lineno &&
|
(line->lineno <= openfile->mark->lineno &&
|
||||||
line->lineno >= openfile->current->lineno))) {
|
line->lineno >= openfile->current->lineno))) {
|
||||||
const linestruct *top, *bot;
|
linestruct *top, *bot;
|
||||||
/* The lines where the marked region begins and ends. */
|
/* The lines where the marked region begins and ends. */
|
||||||
size_t top_x, bot_x;
|
size_t top_x, bot_x;
|
||||||
/* The x positions where the marked region begins and ends. */
|
/* The x positions where the marked region begins and ends. */
|
||||||
|
|
Loading…
Reference in New Issue