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
c22fef18
Commit
c22fef18
authored
7 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: reshuffle a bit of common code, moving it to an existing function
parent
ee5b250b
master
feature/match-parens
refactor/readbility
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/proto.h
+1
-1
src/proto.h
src/text.c
+3
-18
src/text.c
src/utils.c
+13
-7
src/utils.c
with
17 additions
and
26 deletions
+17
-26
src/proto.h
View file @
c22fef18
...
...
@@ -609,7 +609,7 @@ void remove_magicline(void);
#ifndef NANO_TINY
void
mark_order
(
const
filestruct
**
top
,
size_t
*
top_x
,
const
filestruct
**
bot
,
size_t
*
bot_x
,
bool
*
right_side_up
);
void
get_r
egion
(
const
filestruct
**
top
,
const
filestruct
**
bot
);
void
get_r
ange
(
const
filestruct
**
top
,
const
filestruct
**
bot
);
#endif
size_t
get_totsize
(
const
filestruct
*
begin
,
const
filestruct
*
end
);
#ifndef NANO_TINY
...
...
This diff is collapsed.
Click to expand it.
src/text.c
View file @
c22fef18
...
...
@@ -298,12 +298,7 @@ void do_indent(void)
filestruct
*
top
,
*
bot
,
*
line
;
/* Use either all the marked lines or just the current line. */
if
(
openfile
->
mark
)
get_region
((
const
filestruct
**
)
&
top
,
(
const
filestruct
**
)
&
bot
);
else
{
top
=
openfile
->
current
;
bot
=
top
;
}
get_range
((
const
filestruct
**
)
&
top
,
(
const
filestruct
**
)
&
bot
);
/* Go through the lines to see if there's a non-empty one. */
for
(
line
=
top
;
line
!=
bot
->
next
;
line
=
line
->
next
)
{
...
...
@@ -401,12 +396,7 @@ void do_unindent(void)
filestruct
*
top
,
*
bot
,
*
line
;
/* Use either all the marked lines or just the current line. */
if
(
openfile
->
mark
)
get_region
((
const
filestruct
**
)
&
top
,
(
const
filestruct
**
)
&
bot
);
else
{
top
=
openfile
->
current
;
bot
=
top
;
}
get_range
((
const
filestruct
**
)
&
top
,
(
const
filestruct
**
)
&
bot
);
/* Check if there is a line that can be unindented. */
for
(
line
=
top
;
line
!=
bot
->
next
;
line
=
line
->
next
)
{
...
...
@@ -503,12 +493,7 @@ void do_comment(void)
#endif
/* Determine which lines to work on. */
if
(
openfile
->
mark
)
get_region
((
const
filestruct
**
)
&
top
,
(
const
filestruct
**
)
&
bot
);
else
{
top
=
openfile
->
current
;
bot
=
top
;
}
get_range
((
const
filestruct
**
)
&
top
,
(
const
filestruct
**
)
&
bot
);
/* If only the magic line is selected, don't do anything. */
if
(
top
==
bot
&&
bot
==
openfile
->
filebot
&&
!
ISSET
(
NO_NEWLINES
))
{
...
...
This diff is collapsed.
Click to expand it.
src/utils.c
View file @
c22fef18
...
...
@@ -532,16 +532,22 @@ void mark_order(const filestruct **top, size_t *top_x, const filestruct
}
}
/* Get the start and end points of the marked region, but
* push the end point back if it's at the start of a line. */
void
get_region
(
const
filestruct
**
top
,
const
filestruct
**
bot
)
/* 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
* at the start of the last line of the region, exclude that line. */
void
get_range
(
const
filestruct
**
top
,
const
filestruct
**
bot
)
{
size_t
top_x
,
bot_x
;
if
(
!
openfile
->
mark
)
{
*
top
=
openfile
->
current
;
*
bot
=
openfile
->
current
;
}
else
{
size_t
top_x
,
bot_x
;
mark_order
(
top
,
&
top_x
,
bot
,
&
bot_x
,
NULL
);
mark_order
(
top
,
&
top_x
,
bot
,
&
bot_x
,
NULL
);
if
(
bot_x
==
0
&&
*
bot
!=
*
top
)
*
bot
=
(
*
bot
)
->
prev
;
if
(
bot_x
==
0
&&
*
bot
!=
*
top
)
*
bot
=
(
*
bot
)
->
prev
;
}
}
/* Given a line number, return a pointer to the corresponding struct. */
...
...
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