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
1f9a6ab3
Commit
1f9a6ab3
authored
8 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: factor out a bit of common code
parent
33cefa92
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/move.c
+28
-52
src/move.c
with
28 additions
and
52 deletions
+28
-52
src/move.c
View file @
1f9a6ab3
...
...
@@ -49,11 +49,31 @@ void do_last_line(void)
focusing
=
FALSE
;
}
/* Determine the actual current chunk and the target column. */
void
get_edge_and_target
(
size_t
*
leftedge
,
size_t
*
target_column
)
{
#ifndef NANO_TINY
if
(
ISSET
(
SOFTWRAP
))
{
size_t
realspan
=
strlenpt
(
openfile
->
current
->
data
);
if
(
openfile
->
placewewant
<
realspan
)
realspan
=
openfile
->
placewewant
;
*
leftedge
=
(
realspan
/
editwincols
)
*
editwincols
;
*
target_column
=
openfile
->
placewewant
%
editwincols
;
}
else
#endif
{
*
leftedge
=
0
;
*
target_column
=
openfile
->
placewewant
;
}
}
/* Move up nearly one screenful. */
void
do_page_up
(
void
)
{
int
mustmove
=
(
editwinrows
<
3
)
?
1
:
editwinrows
-
2
;
size_t
leftedge
=
0
,
target_column
;
size_t
leftedge
,
target_column
;
/* If we're not in smooth scrolling mode, put the cursor at the
* beginning of the top line of the edit window, as Pico does. */
...
...
@@ -63,18 +83,7 @@ void do_page_up(void)
openfile
->
current_y
=
0
;
}
#ifndef NANO_TINY
if
(
ISSET
(
SOFTWRAP
))
{
size_t
realspan
=
strlenpt
(
openfile
->
current
->
data
);
if
(
openfile
->
placewewant
<
realspan
)
realspan
=
openfile
->
placewewant
;
leftedge
=
(
realspan
/
editwincols
)
*
editwincols
;
target_column
=
openfile
->
placewewant
%
editwincols
;
}
else
#endif
target_column
=
openfile
->
placewewant
;
get_edge_and_target
(
&
leftedge
,
&
target_column
);
/* Move up the required number of lines or chunks. If we can't, we're
* at the top of the file, so put the cursor there and get out. */
...
...
@@ -96,7 +105,7 @@ void do_page_up(void)
void
do_page_down
(
void
)
{
int
mustmove
=
(
editwinrows
<
3
)
?
1
:
editwinrows
-
2
;
size_t
leftedge
=
0
,
target_column
;
size_t
leftedge
,
target_column
;
/* If we're not in smooth scrolling mode, put the cursor at the
* beginning of the top line of the edit window, as Pico does. */
...
...
@@ -106,18 +115,7 @@ void do_page_down(void)
openfile
->
current_y
=
0
;
}
#ifndef NANO_TINY
if
(
ISSET
(
SOFTWRAP
))
{
size_t
realspan
=
strlenpt
(
openfile
->
current
->
data
);
if
(
openfile
->
placewewant
<
realspan
)
realspan
=
openfile
->
placewewant
;
leftedge
=
(
realspan
/
editwincols
)
*
editwincols
;
target_column
=
openfile
->
placewewant
%
editwincols
;
}
else
#endif
target_column
=
openfile
->
placewewant
;
get_edge_and_target
(
&
leftedge
,
&
target_column
);
/* Move down the required number of lines or chunks. If we can't, we're
* at the bottom of the file, so put the cursor there and get out. */
...
...
@@ -463,25 +461,14 @@ void do_up(bool scroll_only)
{
filestruct
*
was_current
=
openfile
->
current
;
size_t
was_column
=
xplustabs
();
size_t
leftedge
=
0
,
target_column
;
size_t
leftedge
,
target_column
;
/* When just scrolling and the top of the file is onscreen, get out. */
if
(
scroll_only
&&
openfile
->
edittop
==
openfile
->
fileage
&&
openfile
->
firstcolumn
==
0
)
return
;
#ifndef NANO_TINY
if
(
ISSET
(
SOFTWRAP
))
{
size_t
realspan
=
strlenpt
(
openfile
->
current
->
data
);
if
(
openfile
->
placewewant
<
realspan
)
realspan
=
openfile
->
placewewant
;
leftedge
=
(
realspan
/
editwincols
)
*
editwincols
;
target_column
=
openfile
->
placewewant
%
editwincols
;
}
else
#endif
target_column
=
openfile
->
placewewant
;
get_edge_and_target
(
&
leftedge
,
&
target_column
);
/* If we can't move up one line or chunk, we're at top of file. */
if
(
go_back_chunks
(
1
,
&
openfile
->
current
,
&
leftedge
)
>
0
)
...
...
@@ -523,20 +510,9 @@ void do_down(bool scroll_only)
{
filestruct
*
was_current
=
openfile
->
current
;
size_t
was_column
=
xplustabs
();
size_t
leftedge
=
0
,
target_column
;
#ifndef NANO_TINY
if
(
ISSET
(
SOFTWRAP
))
{
size_t
realspan
=
strlenpt
(
openfile
->
current
->
data
);
if
(
openfile
->
placewewant
<
realspan
)
realspan
=
openfile
->
placewewant
;
size_t
leftedge
,
target_column
;
leftedge
=
(
realspan
/
editwincols
)
*
editwincols
;
target_column
=
openfile
->
placewewant
%
editwincols
;
}
else
#endif
target_column
=
openfile
->
placewewant
;
get_edge_and_target
(
&
leftedge
,
&
target_column
);
/* If we can't move down one line or chunk, we're at bottom of file. */
if
(
go_forward_chunks
(
1
,
&
openfile
->
current
,
&
leftedge
)
>
0
)
...
...
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