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
dc18746c
Commit
dc18746c
authored
8 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: retype, rename, and reshuffle a function
parent
c92b9be6
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/files.c
+17
-16
src/files.c
src/nano.c
+2
-2
src/nano.c
src/proto.h
+1
-1
src/proto.h
with
20 additions
and
19 deletions
+20
-19
src/files.c
View file @
dc18746c
...
...
@@ -1214,7 +1214,7 @@ void do_insertfile(void)
#ifndef NANO_TINY
if
(
!
execute
)
#endif
if
(
check_poshistory
(
answer
,
&
priorline
,
&
priorcol
))
if
(
has_old_position
(
answer
,
&
priorline
,
&
priorcol
))
do_gotolinecolumn
(
priorline
,
priorcol
,
FALSE
,
FALSE
);
}
#endif
/* !DISABLE_HISTORIES */
...
...
@@ -3146,27 +3146,28 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
free
(
fullpath
);
}
/* Check
the recorded last file positions to see
i
f
the
given file
*
matches an existing entry
. If
so
, return
1 and set line and column
* to the retrieved values.
Otherwise, return 0.
*/
int
check_poshistory
(
const
char
*
file
,
ssize_t
*
line
,
ssize_t
*
column
)
/* Check
whether the given file matches an existing entry
i
n
the
recorded
*
last file positions
. If
not
, return
FALSE. If yes, return TRUE and
*
set line and column
to the retrieved values. */
bool
has_old_position
(
const
char
*
file
,
ssize_t
*
line
,
ssize_t
*
column
)
{
poshiststruct
*
posptr
;
poshiststruct
*
posptr
=
position_history
;
char
*
fullpath
=
get_full_path
(
file
);
if
(
fullpath
==
NULL
)
return
0
;
return
FALSE
;
while
(
posptr
!=
NULL
&&
strcmp
(
posptr
->
filename
,
fullpath
)
!=
0
)
posptr
=
posptr
->
next
;
for
(
posptr
=
position_history
;
posptr
!=
NULL
;
posptr
=
posptr
->
next
)
{
if
(
!
strcmp
(
posptr
->
filename
,
fullpath
))
{
*
line
=
posptr
->
lineno
;
*
column
=
posptr
->
xno
;
free
(
fullpath
);
return
1
;
}
}
free
(
fullpath
);
return
0
;
if
(
posptr
==
NULL
)
return
FALSE
;
*
line
=
posptr
->
lineno
;
*
column
=
posptr
->
xno
;
return
TRUE
;
}
/* Load the recorded file positions from ~/.nano/filepos_history. */
...
...
This diff is collapsed.
Click to expand it.
src/nano.c
View file @
dc18746c
...
...
@@ -2606,7 +2606,7 @@ int main(int argc, char **argv)
else
if
(
ISSET
(
POS_HISTORY
))
{
ssize_t
savedposline
,
savedposcol
;
/* If edited before, restore the last cursor position. */
if
(
check_poshistory
(
argv
[
i
],
&
savedposline
,
&
savedposcol
))
if
(
has_old_position
(
argv
[
i
],
&
savedposline
,
&
savedposcol
))
do_gotolinecolumn
(
savedposline
,
savedposcol
,
FALSE
,
FALSE
);
}
...
...
@@ -2640,7 +2640,7 @@ int main(int argc, char **argv)
else
if
(
ISSET
(
POS_HISTORY
))
{
ssize_t
savedposline
,
savedposcol
;
/* If the file was edited before, restore the last cursor position. */
if
(
check_poshistory
(
argv
[
optind
],
&
savedposline
,
&
savedposcol
))
if
(
has_old_position
(
argv
[
optind
],
&
savedposline
,
&
savedposcol
))
do_gotolinecolumn
(
savedposline
,
savedposcol
,
FALSE
,
FALSE
);
}
#endif
...
...
This diff is collapsed.
Click to expand it.
src/proto.h
View file @
dc18746c
...
...
@@ -354,7 +354,7 @@ int check_dotnano(void);
void
load_poshistory
(
void
);
void
save_poshistory
(
void
);
void
update_poshistory
(
char
*
filename
,
ssize_t
lineno
,
ssize_t
xpos
);
int
check_poshistory
(
const
char
*
file
,
ssize_t
*
line
,
ssize_t
*
column
);
bool
has_old_position
(
const
char
*
file
,
ssize_t
*
line
,
ssize_t
*
column
);
#endif
/* Some functions in global.c. */
...
...
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