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
839743fd
Commit
839743fd
authored
7 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: move a function to its proper location
parent
0b30835d
master
feature/match-parens
refactor/readbility
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/proto.h
+0
-1
src/proto.h
src/text.c
+60
-60
src/text.c
with
60 additions
and
61 deletions
+60
-61
src/proto.h
View file @
839743fd
...
@@ -521,7 +521,6 @@ void do_unindent(void);
...
@@ -521,7 +521,6 @@ void do_unindent(void);
bool
white_string
(
const
char
*
s
);
bool
white_string
(
const
char
*
s
);
#ifdef ENABLE_COMMENT
#ifdef ENABLE_COMMENT
void
do_comment
(
void
);
void
do_comment
(
void
);
bool
comment_line
(
undo_type
action
,
filestruct
*
f
,
const
char
*
comment_seq
);
#endif
#endif
void
do_undo
(
void
);
void
do_undo
(
void
);
void
do_redo
(
void
);
void
do_redo
(
void
);
...
...
This diff is collapsed.
Click to expand it.
src/text.c
View file @
839743fd
...
@@ -476,66 +476,6 @@ bool white_string(const char *s)
...
@@ -476,66 +476,6 @@ bool white_string(const char *s)
}
}
#ifdef ENABLE_COMMENT
#ifdef ENABLE_COMMENT
/* Comment or uncomment the current line or the marked lines. */
void
do_comment
(
void
)
{
const
char
*
comment_seq
=
GENERAL_COMMENT_CHARACTER
;
undo_type
action
=
UNCOMMENT
;
filestruct
*
top
,
*
bot
,
*
line
;
bool
empty
,
all_empty
=
TRUE
;
#ifdef ENABLE_COLOR
if
(
openfile
->
syntax
)
comment_seq
=
openfile
->
syntax
->
comment
;
if
(
*
comment_seq
==
'\0'
)
{
statusbar
(
_
(
"Commenting is not supported for this file type"
));
return
;
}
#endif
/* Determine which lines to work on. */
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
))
{
statusbar
(
_
(
"Cannot comment past end of file"
));
return
;
}
/* Figure out whether to comment or uncomment the selected line or lines. */
for
(
line
=
top
;
line
!=
bot
->
next
;
line
=
line
->
next
)
{
empty
=
white_string
(
line
->
data
);
/* If this line is not blank and not commented, we comment all. */
if
(
!
empty
&&
!
comment_line
(
PREFLIGHT
,
line
,
comment_seq
))
{
action
=
COMMENT
;
break
;
}
all_empty
=
all_empty
&&
empty
;
}
/* If all selected lines are blank, we comment them. */
action
=
all_empty
?
COMMENT
:
action
;
add_undo
(
action
);
/* Store the comment sequence used for the operation, because it could
* change when the file name changes; we need to know what it was. */
openfile
->
current_undo
->
strdata
=
mallocstrcpy
(
NULL
,
comment_seq
);
/* Process the selected line or lines. */
for
(
line
=
top
;
line
!=
bot
->
next
;
line
=
line
->
next
)
{
/* Comment/uncomment a line, and add undo data when line changed. */
if
(
comment_line
(
action
,
line
,
comment_seq
))
update_multiline_undo
(
line
->
lineno
,
""
);
}
set_modified
();
refresh_needed
=
TRUE
;
shift_held
=
TRUE
;
}
/* Test whether the given line can be uncommented, or add or remove a comment,
/* Test whether the given line can be uncommented, or add or remove a comment,
* depending on action. Return TRUE if the line is uncommentable, or when
* depending on action. Return TRUE if the line is uncommentable, or when
* anything was added or removed; FALSE otherwise. */
* anything was added or removed; FALSE otherwise. */
...
@@ -598,6 +538,66 @@ bool comment_line(undo_type action, filestruct *line, const char *comment_seq)
...
@@ -598,6 +538,66 @@ bool comment_line(undo_type action, filestruct *line, const char *comment_seq)
return
FALSE
;
return
FALSE
;
}
}
/* Comment or uncomment the current line or the marked lines. */
void
do_comment
(
void
)
{
const
char
*
comment_seq
=
GENERAL_COMMENT_CHARACTER
;
undo_type
action
=
UNCOMMENT
;
filestruct
*
top
,
*
bot
,
*
line
;
bool
empty
,
all_empty
=
TRUE
;
#ifdef ENABLE_COLOR
if
(
openfile
->
syntax
)
comment_seq
=
openfile
->
syntax
->
comment
;
if
(
*
comment_seq
==
'\0'
)
{
statusbar
(
_
(
"Commenting is not supported for this file type"
));
return
;
}
#endif
/* Determine which lines to work on. */
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
))
{
statusbar
(
_
(
"Cannot comment past end of file"
));
return
;
}
/* Figure out whether to comment or uncomment the selected line or lines. */
for
(
line
=
top
;
line
!=
bot
->
next
;
line
=
line
->
next
)
{
empty
=
white_string
(
line
->
data
);
/* If this line is not blank and not commented, we comment all. */
if
(
!
empty
&&
!
comment_line
(
PREFLIGHT
,
line
,
comment_seq
))
{
action
=
COMMENT
;
break
;
}
all_empty
=
all_empty
&&
empty
;
}
/* If all selected lines are blank, we comment them. */
action
=
all_empty
?
COMMENT
:
action
;
add_undo
(
action
);
/* Store the comment sequence used for the operation, because it could
* change when the file name changes; we need to know what it was. */
openfile
->
current_undo
->
strdata
=
mallocstrcpy
(
NULL
,
comment_seq
);
/* Process the selected line or lines. */
for
(
line
=
top
;
line
!=
bot
->
next
;
line
=
line
->
next
)
{
/* Comment/uncomment a line, and add undo data when line changed. */
if
(
comment_line
(
action
,
line
,
comment_seq
))
update_multiline_undo
(
line
->
lineno
,
""
);
}
set_modified
();
refresh_needed
=
TRUE
;
shift_held
=
TRUE
;
}
/* Perform an undo or redo for a comment or uncomment action. */
/* Perform an undo or redo for a comment or uncomment action. */
void
handle_comment_action
(
undo
*
u
,
bool
undoing
,
bool
add_comment
)
void
handle_comment_action
(
undo
*
u
,
bool
undoing
,
bool
add_comment
)
{
{
...
...
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