Skip to content
GitLab
Menu
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
1b2a091d
Commit
1b2a091d
authored
7 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: condense or improve some comments
Also reshuffle an initialization and drop two useless asserts.
parent
bd770ea2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/text.c
+11
-22
src/text.c
with
11 additions
and
22 deletions
+11
-22
src/text.c
View file @
1b2a091d
...
...
@@ -280,35 +280,27 @@ void do_tab(void)
* depending on whether --tabstospaces is in effect. */
void
do_indent
(
void
)
{
char
*
line_indent
=
NULL
;
/* The
text
added to each line in order to indent it. */
char
*
line_indent
=
charalloc
(
tabsize
+
1
)
;
/* The
whitespace
added to each line in order to indent it. */
size_t
line_indent_len
=
0
;
/* The length of the text added to each line in order to indent
* it. */
/* The number of bytes added to each line in order to indent it. */
filestruct
*
top
,
*
bot
,
*
f
;
size_t
top_x
,
bot_x
;
assert
(
openfile
->
current
!=
NULL
&&
openfile
->
current
->
data
!=
NULL
);
/* If the mark is on, use all lines covered by the mark. */
/* Use either all the marked lines or just the current line. */
if
(
openfile
->
mark_set
)
mark_order
((
const
filestruct
**
)
&
top
,
&
top_x
,
(
const
filestruct
**
)
&
bot
,
&
bot_x
,
NULL
);
/* Otherwise, use the current line. */
else
{
top
=
openfile
->
current
;
bot
=
top
;
}
/* Set up the text we'll be using as indentation. */
line_indent
=
charalloc
(
tabsize
+
1
);
/* Set the indentation to either a bunch of spaces or a single tab. */
if
(
ISSET
(
TABS_TO_SPACES
))
{
/* Set the indentation to tabsize spaces. */
charset
(
line_indent
,
' '
,
tabsize
);
line_indent_len
=
tabsize
;
}
else
{
/* Set the indentation to a tab. */
line_indent
[
0
]
=
'\t'
;
line_indent_len
=
1
;
}
...
...
@@ -386,33 +378,30 @@ void do_unindent(void)
filestruct
*
top
,
*
bot
,
*
f
;
size_t
top_x
,
bot_x
;
assert
(
openfile
->
current
!=
NULL
&&
openfile
->
current
->
data
!=
NULL
);
/* If the mark is on, use all lines covered by the mark. */
/* Use either all the marked lines or just the current line. */
if
(
openfile
->
mark_set
)
mark_order
((
const
filestruct
**
)
&
top
,
&
top_x
,
(
const
filestruct
**
)
&
bot
,
&
bot_x
,
NULL
);
/* Otherwise, use the current line. */
else
{
top
=
openfile
->
current
;
bot
=
top
;
}
/*
Go through
the lines
to check whether they a) are empty or blank
* o
r b) start with a tab's worth of whitespace
. */
/*
If any of
the lines
cannot be unindented and does not consist of
* o
nly whitespace, we don't change anything
. */
for
(
f
=
top
;
f
!=
bot
->
next
;
f
=
f
->
next
)
{
if
(
!
white_string
(
f
->
data
)
&&
length_of_white
(
f
->
data
)
==
0
)
{
if
(
length_of_white
(
f
->
data
)
==
0
&&
!
white_string
(
f
->
data
)
)
{
statusline
(
HUSH
,
_
(
"Can unindent only by a full tab size"
));
return
;
}
}
/* Go through each
line of the tex
t. */
/* Go through each
of the lines and remove their leading inden
t. */
for
(
f
=
top
;
f
!=
bot
->
next
;
f
=
f
->
next
)
{
size_t
line_len
=
strlen
(
f
->
data
);
size_t
indent_len
=
length_of_white
(
f
->
data
);
/* If th
e
line c
onsists of a small amount of whitespace,
skip it. */
/* If th
is
line c
annot be unindeted, simply
skip it. */
if
(
indent_len
==
0
)
continue
;
...
...
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