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
83b89a49
Commit
83b89a49
authored
8 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
text: remove a redundant undo element
Implement its single use case by making better use of another element.
parent
87a25440
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/nano.h
+7
-6
src/nano.h
src/text.c
+4
-5
src/text.c
with
11 additions
and
11 deletions
+11
-11
src/nano.h
View file @
83b89a49
...
...
@@ -357,13 +357,12 @@ typedef struct undo {
/* Copy of the cutbuffer. */
filestruct
*
cutbottom
;
/* Copy of cutbottom. */
bool
mark_set
;
/* Was the marker set when we cut? */
ssize_t
mark_begin_lineno
;
/*
copy copy copy
*/
/*
Mostly the line number of the current line; sometimes something else.
*/
size_t
mark_begin_x
;
/*
Another shadow variable
. */
/*
The x position corresponding to the above line number
. */
struct
undo
*
next
;
/* A pointer to the undo item of the preceding action. */
}
undo
;
#endif
/* !NANO_TINY */
...
...
@@ -574,8 +573,10 @@ enum
/* Some extra flags for the undo function. */
#define WAS_FINAL_BACKSPACE (1<<1)
#define WAS_MARKED_FORWARD (1<<2)
#define WAS_WHOLE_LINE (1<<3)
#define WAS_WHOLE_LINE (1<<2)
/* The flags for the mark need to be the highest. */
#define MARK_WAS_SET (1<<3)
#define WAS_MARKED_FORWARD (1<<4)
#endif
/* !NANO_TINY */
/* The maximum number of entries displayed in the main shortcut list. */
...
...
This diff is collapsed.
Click to expand it.
src/text.c
View file @
83b89a49
...
...
@@ -1156,7 +1156,7 @@ void add_undo(undo_type action)
* no cursor movement in between -- don't add a new undo item. */
if
(
u
&&
u
->
mark_begin_lineno
==
openfile
->
current
->
lineno
&&
action
==
openfile
->
last_action
&&
((
action
==
ADD
&&
u
->
type
==
ADD
&&
u
->
mark_begin_x
==
openfile
->
current_x
)
||
(
action
==
CUT
&&
u
->
type
==
CUT
&&
!
u
->
mark_set
&&
keeping_cutbuffer
())))
(
action
==
CUT
&&
u
->
type
==
CUT
&&
u
->
xflags
<
MARK_WAS_SET
&&
keeping_cutbuffer
())))
return
;
/* Blow away newer undo items if we add somewhere in the middle. */
...
...
@@ -1190,7 +1190,6 @@ void add_undo(undo_type action)
u
->
begin
=
openfile
->
current_x
;
u
->
mark_begin_lineno
=
openfile
->
current
->
lineno
;
u
->
mark_begin_x
=
openfile
->
current_x
;
u
->
mark_set
=
FALSE
;
u
->
wassize
=
openfile
->
totsize
;
u
->
xflags
=
0
;
u
->
grouping
=
NULL
;
...
...
@@ -1244,10 +1243,10 @@ void add_undo(undo_type action)
break
;
case
CUT
:
cutbuffer_reset
();
u
->
mark_set
=
openfile
->
mark_set
;
if
(
u
->
mark_set
)
{
if
(
openfile
->
mark_set
)
{
u
->
mark_begin_lineno
=
openfile
->
mark_begin
->
lineno
;
u
->
mark_begin_x
=
openfile
->
mark_begin_x
;
u
->
xflags
=
MARK_WAS_SET
;
}
else
if
(
!
ISSET
(
CUT_TO_END
))
{
/* The entire line is being cut regardless of the cursor position. */
u
->
begin
=
0
;
...
...
@@ -1379,7 +1378,7 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
break
;
free_filestruct
(
u
->
cutbuffer
);
u
->
cutbuffer
=
copy_filestruct
(
cutbuffer
);
if
(
u
->
mark_set
)
{
if
(
u
->
xflags
==
MARK_WAS_SET
)
{
/* If the "marking" operation was from right-->left or
* bottom-->top, then swap the mark points. */
if
((
u
->
lineno
==
u
->
mark_begin_lineno
&&
u
->
begin
<
u
->
mark_begin_x
)
...
...
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