Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs24-19fa
git_rec_nano
Commits
95f417fa
Commit
95f417fa
authored
8 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: rewrap a bunch of lines and some comments
parent
49cb559c
master
feature/match-parens
refactor/readbility
No related merge requests found
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
src/files.c
+1
-2
src/files.c
src/nano.c
+33
-50
src/nano.c
src/search.c
+1
-1
src/search.c
src/text.c
+10
-10
src/text.c
src/utils.c
+5
-4
src/utils.c
src/winio.c
+15
-19
src/winio.c
with
65 additions
and
86 deletions
+65
-86
src/files.c
View file @
95f417fa
...
...
@@ -1178,8 +1178,7 @@ void do_insertfile(
size_t
top_x
,
bot_x
;
mark_order
((
const
filestruct
**
)
&
top
,
&
top_x
,
(
const
filestruct
**
)
&
bot
,
&
bot_x
,
&
right_side_up
);
(
const
filestruct
**
)
&
bot
,
&
bot_x
,
&
right_side_up
);
single_line
=
(
top
==
bot
);
}
...
...
This diff is collapsed.
Click to expand it.
src/nano.c
View file @
95f417fa
...
...
@@ -218,17 +218,15 @@ partition *partition_filestruct(filestruct *top, size_t top_x,
}
else
p
->
filebot
=
NULL
;
/* Save the line above the top of the partition, detach the top of
* the partition from it, and save the text before top_x in
* top_data. */
/* Remember which line is above the top of the partition, detach the
* top of the partition from it, and save the text before top_x. */
p
->
top_prev
=
top
->
prev
;
top
->
prev
=
NULL
;
p
->
top_data
=
mallocstrncpy
(
NULL
,
top
->
data
,
top_x
+
1
);
p
->
top_data
[
top_x
]
=
'\0'
;
/* Save the line below the bottom of the partition, detach the
* bottom of the partition from it, and save the text after bot_x in
* bot_data. */
/* Remember which line is below the bottom of the partition, detach the
* bottom of the partition from it, and save the text after bot_x. */
p
->
bot_next
=
bot
->
next
;
bot
->
next
=
NULL
;
p
->
bot_data
=
mallocstrcpy
(
NULL
,
bot
->
data
+
bot_x
);
...
...
@@ -237,8 +235,7 @@ partition *partition_filestruct(filestruct *top, size_t top_x,
null_at
(
&
bot
->
data
,
bot_x
);
/* Remove all text before top_x at the top of the partition. */
charmove
(
top
->
data
,
top
->
data
+
top_x
,
strlen
(
top
->
data
)
-
top_x
+
1
);
charmove
(
top
->
data
,
top
->
data
+
top_x
,
strlen
(
top
->
data
)
-
top_x
+
1
);
align
(
&
top
->
data
);
/* Return the partition. */
...
...
@@ -315,9 +312,8 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
* the edit window is inside the partition, and keep track of
* whether the mark begins inside the partition. */
filepart
=
partition_filestruct
(
top
,
top_x
,
bot
,
bot_x
);
edittop_inside
=
(
openfile
->
edittop
->
lineno
>=
openfile
->
fileage
->
lineno
&&
openfile
->
edittop
->
lineno
<=
openfile
->
filebot
->
lineno
);
edittop_inside
=
(
openfile
->
edittop
->
lineno
>=
openfile
->
fileage
->
lineno
&&
openfile
->
edittop
->
lineno
<=
openfile
->
filebot
->
lineno
);
#ifndef NANO_TINY
if
(
openfile
->
mark_set
)
{
mark_inside
=
(
openfile
->
mark_begin
->
lineno
>=
...
...
@@ -332,8 +328,7 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
}
#endif
/* Get the number of characters in the text, and subtract it from
* totsize. */
/* Subtract the number of characters in the text from the file size. */
openfile
->
totsize
-=
get_totsize
(
top
,
bot
);
if
(
*
file_top
==
NULL
)
{
...
...
@@ -343,7 +338,7 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
*
file_top
=
openfile
->
fileage
;
*
file_bot
=
openfile
->
filebot
;
/* Renumber starting with file_top. */
/* Renumber
,
starting with file_top. */
renumber
(
*
file_top
);
}
else
{
filestruct
*
file_bot_save
=
*
file_bot
;
...
...
@@ -366,13 +361,11 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
delete_node
(
openfile
->
fileage
);
/* Renumber starting with the line after the original
* file_bot. */
/* Renumber, starting with the line after the original file_bot. */
renumber
(
file_bot_save
->
next
);
}
/* Since the text has now been saved, remove it from the
* filestruct. */
/* Since the text has now been saved, remove it from the filestruct. */
openfile
->
fileage
=
(
filestruct
*
)
nmalloc
(
sizeof
(
filestruct
));
openfile
->
fileage
->
data
=
mallocstrcpy
(
NULL
,
""
);
openfile
->
filebot
=
openfile
->
fileage
;
...
...
@@ -408,12 +401,10 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
refresh_needed
=
TRUE
;
}
/* Renumber starting with the beginning line of the old
* partition. */
/* Renumber, starting with the beginning line of the old partition. */
renumber
(
top_save
);
/* If the NO_NEWLINES flag isn't set, and the text doesn't end with
* a magicline, add a new magicline. */
/* If the text doesn't end with a magicline, and it should, add one. */
if
(
!
ISSET
(
NO_NEWLINES
)
&&
openfile
->
filebot
->
data
[
0
]
!=
'\0'
)
new_magicline
();
}
...
...
@@ -445,11 +436,10 @@ void copy_from_filestruct(filestruct *somebuffer)
}
#endif
/* Partition the filestruct so that it contains no text, and keep
* track of whether the top of the edit window is inside the
* partition. */
filepart
=
partition_filestruct
(
openfile
->
current
,
openfile
->
current_x
,
openfile
->
current
,
openfile
->
current_x
);
/* Partition the filestruct so that it contains no text, and remember
* whether the top of the edit window is at the start of the buffer. */
filepart
=
partition_filestruct
(
openfile
->
current
,
openfile
->
current_x
,
openfile
->
current
,
openfile
->
current_x
);
edittop_inside
=
(
openfile
->
edittop
==
openfile
->
fileage
);
/* Put the top and bottom of the current filestruct at the top and
...
...
@@ -489,10 +479,8 @@ void copy_from_filestruct(filestruct *somebuffer)
}
#endif
/* Get the number of characters in the copied text, and add it to
* totsize. */
openfile
->
totsize
+=
get_totsize
(
openfile
->
fileage
,
openfile
->
filebot
);
/* Add the number of characters in the copied text to the file size. */
openfile
->
totsize
+=
get_totsize
(
openfile
->
fileage
,
openfile
->
filebot
);
/* Update the current y-coordinate to account for the number of
* lines the copied text has, less one since the first line will be
...
...
@@ -510,12 +498,10 @@ void copy_from_filestruct(filestruct *somebuffer)
* again, plus the copied text. */
unpartition_filestruct
(
&
filepart
);
/* Renumber starting with the beginning line of the old
* partition. */
/* Renumber, starting with the beginning line of the old partition. */
renumber
(
top_save
);
/* If the NO_NEWLINES flag isn't set, and the text doesn't end with
* a magicline, add a new magicline. */
/* If the text doesn't end with a magicline, and it should, add one. */
if
(
!
ISSET
(
NO_NEWLINES
)
&&
openfile
->
filebot
->
data
[
0
]
!=
'\0'
)
new_magicline
();
}
...
...
@@ -1864,12 +1850,11 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
#endif
while
(
i
<
output_len
)
{
/* If allow_cntrls is TRUE, convert nulls and newlines properly. */
/* If control codes are allowed, encode a null as a newline, and
* let a newline character create a whole new line. */
if
(
allow_cntrls
)
{
/* Null to newline, if needed. */
if
(
output
[
i
]
==
'\0'
)
output
[
i
]
=
'\n'
;
/* Newline to Enter, if needed. */
else
if
(
output
[
i
]
==
'\n'
)
{
do_enter
();
i
++
;
...
...
@@ -1877,26 +1862,24 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
}
}
/*
Interpr
et the next multibyte character. */
/*
G
et the next multibyte character. */
char_buf_len
=
parse_mbchar
(
output
+
i
,
char_buf
,
NULL
);
i
+=
char_buf_len
;
/* If
allow_
cntrls
is FALSE, filter out
an ASCII control character. */
/* If c
o
ntr
o
ls
are not allowed, ignore
an ASCII control character. */
if
(
!
allow_cntrls
&&
is_ascii_cntrl_char
(
*
(
output
+
i
-
char_buf_len
)))
continue
;
/* If the NO_NEWLINES flag isn't set, when a character is
* added to the magicline, it means we need a new magicline. */
/* If we're adding to the magicline, create a new magicline. */
if
(
!
ISSET
(
NO_NEWLINES
)
&&
openfile
->
filebot
==
openfile
->
current
)
new_magicline
();
/* More dangerousness fun =) */
openfile
->
current
->
data
=
charealloc
(
openfile
->
current
->
data
,
current_len
+
char_buf_len
+
1
);
assert
(
openfile
->
current_x
<=
current_len
);
/* Make room for the new character and copy it into the line. */
openfile
->
current
->
data
=
charealloc
(
openfile
->
current
->
data
,
current_len
+
char_buf_len
+
1
);
charmove
(
openfile
->
current
->
data
+
openfile
->
current_x
+
char_buf_len
,
openfile
->
current
->
data
+
openfile
->
current_x
,
current_len
-
openfile
->
current_x
+
1
);
...
...
This diff is collapsed.
Click to expand it.
src/search.c
View file @
95f417fa
This diff is collapsed.
Click to expand it.
src/text.c
View file @
95f417fa
...
...
@@ -472,8 +472,8 @@ void do_comment()
/* Determine which lines to work on. */
if
(
openfile
->
mark_set
)
mark_order
((
const
filestruct
**
)
&
top
,
&
top_x
,
(
const
filestruct
**
)
&
bot
,
&
bot_x
,
NULL
);
mark_order
((
const
filestruct
**
)
&
top
,
&
top_x
,
(
const
filestruct
**
)
&
bot
,
&
bot_x
,
NULL
);
else
{
top
=
openfile
->
current
;
bot
=
top
;
...
...
This diff is collapsed.
Click to expand it.
src/utils.c
View file @
95f417fa
...
...
@@ -540,7 +540,8 @@ void remove_magicline(void)
{
if
(
openfile
->
filebot
->
data
[
0
]
==
'\0'
&&
openfile
->
filebot
!=
openfile
->
fileage
)
{
assert
(
openfile
->
filebot
!=
openfile
->
edittop
&&
openfile
->
filebot
!=
openfile
->
current
);
assert
(
openfile
->
filebot
!=
openfile
->
edittop
&&
openfile
->
filebot
!=
openfile
->
current
);
openfile
->
filebot
=
openfile
->
filebot
->
prev
;
free_filestruct
(
openfile
->
filebot
->
next
);
...
...
This diff is collapsed.
Click to expand it.
src/winio.c
View file @
95f417fa
...
...
@@ -2586,21 +2586,19 @@ void edit_draw(filestruct *fileptr, const char *converted, int
#endif
/* !DISABLE_COLOR */
#ifndef NANO_TINY
/* If the mark is on, we need to display it. */
if
(
openfile
->
mark_set
&&
(
fileptr
->
lineno
<=
openfile
->
mark_begin
->
lineno
||
fileptr
->
lineno
<=
openfile
->
current
->
lineno
)
&&
(
fileptr
->
lineno
>=
openfile
->
mark_begin
->
lineno
||
fileptr
->
lineno
>=
openfile
->
current
->
lineno
))
{
/* fileptr is at least partially selected. */
const
filestruct
*
top
;
/* Either current or mark_begin, whichever is first. */
size_t
top_x
;
/* current_x or mark_begin_x, corresponding to top. */
const
filestruct
*
bot
;
size_t
bot_x
;
/* If the mark is on, and fileptr is at least partially selected, we
* need to paint it. */
if
(
openfile
->
mark_set
&&
(
fileptr
->
lineno
<=
openfile
->
mark_begin
->
lineno
||
fileptr
->
lineno
<=
openfile
->
current
->
lineno
)
&&
(
fileptr
->
lineno
>=
openfile
->
mark_begin
->
lineno
||
fileptr
->
lineno
>=
openfile
->
current
->
lineno
))
{
const
filestruct
*
top
,
*
bot
;
/* The lines where the marked region begins and ends. */
size_t
top_x
,
bot_x
;
/* The x positions where the marked region begins and ends. */
int
x_start
;
/*
S
tarting column for mvwaddnstr(). Zero-based. */
/*
The s
tarting column for mvwaddnstr(). Zero-based. */
int
paintlen
;
/* Number of characters to paint on this line. There are
* COLS characters on a whole line. */
...
...
@@ -2614,7 +2612,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
if
(
bot
->
lineno
>
fileptr
->
lineno
||
bot_x
>
endpos
)
bot_x
=
endpos
;
/*
The select
ed bit of fileptr is on this page. */
/*
Only paint if the mark
ed bit of fileptr is on this page. */
if
(
top_x
<
endpos
&&
bot_x
>
startpos
)
{
assert
(
startpos
<=
top_x
);
...
...
@@ -2630,8 +2628,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
if
(
bot_x
>=
endpos
)
paintlen
=
-
1
;
else
paintlen
=
strnlenpt
(
fileptr
->
data
,
bot_x
)
-
(
x_start
+
start
);
paintlen
=
strnlenpt
(
fileptr
->
data
,
bot_x
)
-
(
x_start
+
start
);
/* If x_start is before the beginning of the page, shift
* paintlen x_start characters to compensate, and put
...
...
@@ -2649,8 +2646,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
paintlen
=
actual_x
(
converted
+
index
,
paintlen
);
wattron
(
edit
,
hilite_attribute
);
mvwaddnstr
(
edit
,
line
,
x_start
,
converted
+
index
,
paintlen
);
mvwaddnstr
(
edit
,
line
,
x_start
,
converted
+
index
,
paintlen
);
wattroff
(
edit
,
hilite_attribute
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help