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
fbde1b2d
Commit
fbde1b2d
authored
7 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: reshuffle another bit of code, for conciseness
parent
c22fef18
master
feature/match-parens
refactor/readbility
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/text.c
+11
-16
src/text.c
with
11 additions
and
16 deletions
+11
-16
src/text.c
View file @
fbde1b2d
...
...
@@ -293,24 +293,21 @@ void indent_a_line(filestruct *line, char *indentation)
* depending on whether --tabstospaces is in effect. */
void
do_indent
(
void
)
{
char
*
indentation
=
charalloc
(
tabsize
+
1
);
/* The whitespace added to each line in order to indent it. */
char
*
indentation
;
filestruct
*
top
,
*
bot
,
*
line
;
/* Use either all the marked lines or just the current line. */
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
)
{
if
(
line
->
data
[
0
]
!=
'\0'
)
break
;
}
/* Skip any leading empty lines. */
while
(
top
!=
bot
->
next
&&
top
->
data
[
0
]
==
'\0'
)
top
=
top
->
next
;
/* If all lines are empty, there is nothing to do. */
if
(
line
==
bot
->
next
)
{
free
(
indentation
);
if
(
top
==
bot
->
next
)
return
;
}
indentation
=
charalloc
(
tabsize
+
1
);
/* Set the indentation to either a bunch of spaces or a single tab. */
if
(
ISSET
(
TABS_TO_SPACES
))
{
...
...
@@ -398,14 +395,12 @@ void do_unindent(void)
/* Use either all the marked lines or just the current line. */
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
)
{
if
(
length_of_white
(
line
->
data
)
!=
0
)
break
;
}
/* Skip any leading lines that cannot be unindented. */
while
(
top
!=
bot
->
next
&&
length_of_white
(
top
->
data
)
==
0
)
top
=
top
->
next
;
/* If none of the lines can be unindented, there is nothing to do. */
if
(
line
==
bot
->
next
)
if
(
top
==
bot
->
next
)
return
;
add_undo
(
UNINDENT
);
...
...
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