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
13176792
Commit
13176792
authored
8 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: frob some comments, elide a variable, and use 'while' loops
parent
d7fbc70a
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/nano.c
+18
-18
src/nano.c
with
18 additions
and
18 deletions
+18
-18
src/nano.c
View file @
13176792
...
...
@@ -1732,15 +1732,14 @@ int do_mouse(void)
int
mouse_x
,
mouse_y
;
int
retval
=
get_mouseinput
(
&
mouse_x
,
&
mouse_y
,
TRUE
);
/* If the click is wrong or already handled, we're done. */
if
(
retval
!=
0
)
/* The click is wrong or already handled. */
return
retval
;
/*
We can
click
o
n the edit window
to move
the cursor. */
/*
If the
click
was i
n the edit window
, put
the cursor
in that spot
. */
if
(
wmouse_trafo
(
edit
,
&
mouse_y
,
&
mouse_x
,
FALSE
))
{
bool
sameline
=
(
mouse_y
==
openfile
->
current_y
);
/* Did they click on the line with the cursor? If they
* clicked on the cursor, we set the mark. */
/* Whether the click was on the line where the cursor is. */
filestruct
*
current_save
=
openfile
->
current
;
#ifndef NANO_TINY
size_t
current_x_save
=
openfile
->
current_x
;
...
...
@@ -1752,20 +1751,20 @@ int do_mouse(void)
#ifndef NANO_TINY
if
(
ISSET
(
SOFTWRAP
))
{
ssize_t
i
=
0
,
current_row
=
0
;
ssize_t
current_row
=
0
;
openfile
->
current
=
openfile
->
edittop
;
while
(
openfile
->
current
->
next
!=
NULL
&&
i
<
mouse_y
)
{
current_row
=
i
;
i
+=
strlenpt
(
openfile
->
current
->
data
)
/
editwincols
+
1
;
while
(
openfile
->
current
->
next
!=
NULL
&&
current_row
<
mouse_y
)
{
current_row
+=
strlenpt
(
openfile
->
current
->
data
)
/
editwincols
+
1
;
openfile
->
current
=
openfile
->
current
->
next
;
}
if
(
i
>
mouse_y
)
{
if
(
current_row
>
mouse_y
)
{
openfile
->
current
=
openfile
->
current
->
prev
;
current_row
-=
strlenpt
(
openfile
->
current
->
data
)
/
editwincols
+
1
;
openfile
->
current_x
=
actual_x
(
openfile
->
current
->
data
,
((
mouse_y
-
current_row
)
*
editwincols
)
+
mouse_x
);
((
mouse_y
-
current_row
)
*
editwincols
)
+
mouse_x
);
}
else
openfile
->
current_x
=
actual_x
(
openfile
->
current
->
data
,
mouse_x
);
}
else
...
...
@@ -1774,21 +1773,22 @@ int do_mouse(void)
ssize_t
current_row
=
openfile
->
current_y
;
/* Move to where the click occurred. */
for
(;
current_row
<
mouse_y
&&
openfile
->
current
!=
openfile
->
filebot
;
current_row
++
)
while
(
current_row
<
mouse_y
&&
openfile
->
current
->
next
!=
NULL
)
{
openfile
->
current
=
openfile
->
current
->
next
;
for
(;
current_row
>
mouse_y
&&
openfile
->
current
!=
openfile
->
fileage
;
current_row
--
)
current_row
++
;
}
while
(
current_row
>
mouse_y
&&
openfile
->
current
->
prev
!=
NULL
)
{
openfile
->
current
=
openfile
->
current
->
prev
;
current_row
--
;
}
openfile
->
current_x
=
actual_x
(
openfile
->
current
->
data
,
get_page_start
(
xplustabs
())
+
mouse_x
);
get_page_start
(
xplustabs
())
+
mouse_x
);
}
#ifndef NANO_TINY
/* Clicking where the cursor is toggles the mark, as does
* clicking beyond the line length with the cursor at the end of
* the line. */
/* Clicking where the cursor is toggles the mark, as does clicking
* beyond the line length with the cursor at the end of the line. */
if
(
sameline
&&
openfile
->
current_x
==
current_x_save
)
do_mark
();
else
...
...
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