Skip to content
GitLab
Menu
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
fbbf501f
Commit
fbbf501f
authored
7 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: rename four functions, to be more distinct
parent
ac7a0718
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
src/cut.c
+1
-1
src/cut.c
src/files.c
+1
-1
src/files.c
src/move.c
+9
-9
src/move.c
src/nano.c
+5
-5
src/nano.c
src/proto.h
+4
-4
src/proto.h
src/search.c
+1
-1
src/search.c
src/text.c
+2
-2
src/text.c
src/winio.c
+23
-25
src/winio.c
with
46 additions
and
48 deletions
+46
-48
src/cut.c
View file @
fbbf501f
...
...
@@ -270,7 +270,7 @@ void do_uncut_text(void)
add_undo
(
PASTE
);
if
(
ISSET
(
SOFTWRAP
))
was_leftedge
=
get_chunk_leftedge
(
openfile
->
current
,
xplustabs
()
);
was_leftedge
=
leftedge_for
(
xplustabs
(),
openfile
->
current
);
#endif
/* Add a copy of the text in the cutbuffer to the current buffer
...
...
This diff is collapsed.
Click to expand it.
src/files.c
View file @
fbbf501f
...
...
@@ -777,7 +777,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
add_undo
(
INSERT
);
if
(
ISSET
(
SOFTWRAP
))
was_leftedge
=
get_chunk_leftedge
(
openfile
->
current
,
xplustabs
()
);
was_leftedge
=
leftedge_for
(
xplustabs
(),
openfile
->
current
);
#endif
/* Create an empty buffer. */
...
...
This diff is collapsed.
Click to expand it.
src/move.c
View file @
fbbf501f
...
...
@@ -53,7 +53,7 @@ void get_edge_and_target(size_t *leftedge, size_t *target_column)
{
#ifndef NANO_TINY
if
(
ISSET
(
SOFTWRAP
))
{
*
leftedge
=
get_chunk_leftedge
(
openfile
->
current
,
xplustabs
()
);
*
leftedge
=
leftedge_for
(
xplustabs
(),
openfile
->
current
);
*
target_column
=
openfile
->
placewewant
-
*
leftedge
;
}
else
#endif
...
...
@@ -348,7 +348,7 @@ void do_home(bool be_clever)
size_t
leftedge
=
0
,
leftedge_x
=
0
;
if
(
ISSET
(
SOFTWRAP
))
{
leftedge
=
get_chunk_leftedge
(
openfile
->
current
,
was_column
);
leftedge
=
leftedge_for
(
was_column
,
openfile
->
current
);
leftedge_x
=
actual_x
(
openfile
->
current
->
data
,
leftedge
);
}
...
...
@@ -414,7 +414,7 @@ void do_end(bool be_clever)
#ifndef NANO_TINY
if
(
ISSET
(
SOFTWRAP
))
{
bool
last_chunk
=
FALSE
;
size_t
leftedge
=
get_chunk_leftedge
(
openfile
->
current
,
was_column
);
size_t
leftedge
=
leftedge_for
(
was_column
,
openfile
->
current
);
size_t
rightedge
=
get_softwrap_breakpoint
(
openfile
->
current
->
data
,
leftedge
,
&
last_chunk
);
size_t
rightedge_x
;
...
...
@@ -572,7 +572,7 @@ void do_left(void)
size_t
was_column
=
xplustabs
();
#ifndef NANO_TINY
filestruct
*
was_current
=
openfile
->
current
;
size_t
was_chunk
=
get_
chunk_
row
(
was_c
urrent
,
was_c
olumn
);
size_t
was_chunk
=
chunk_
for
(
was_c
olumn
,
was_c
urrent
);
#endif
if
(
openfile
->
current_x
>
0
)
...
...
@@ -591,8 +591,8 @@ void do_left(void)
* we're now above the first line of the edit window, so scroll up. */
if
(
ISSET
(
SOFTWRAP
)
&&
openfile
->
current_y
==
0
&&
openfile
->
current
==
was_current
&&
get_
chunk_
row
(
openfile
->
curre
nt
,
openfile
->
placewewa
nt
)
!=
was_chunk
)
{
chunk_
for
(
openfile
->
placewewa
nt
,
openfile
->
curre
nt
)
!=
was_chunk
)
{
edit_scroll
(
UPWARD
,
ISSET
(
SMOOTH_SCROLL
)
?
1
:
editwinrows
/
2
+
1
);
return
;
}
...
...
@@ -609,7 +609,7 @@ void do_right(void)
size_t
was_column
=
xplustabs
();
#ifndef NANO_TINY
filestruct
*
was_current
=
openfile
->
current
;
size_t
was_chunk
=
get_
chunk_
row
(
was_c
urrent
,
was_c
olumn
);
size_t
was_chunk
=
chunk_
for
(
was_c
olumn
,
was_c
urrent
);
#endif
if
(
openfile
->
current
->
data
[
openfile
->
current_x
]
!=
'\0'
)
...
...
@@ -628,8 +628,8 @@ void do_right(void)
* we're now below the first line of the edit window, so scroll down. */
if
(
ISSET
(
SOFTWRAP
)
&&
openfile
->
current_y
==
editwinrows
-
1
&&
openfile
->
current
==
was_current
&&
get_
chunk_
row
(
openfile
->
curre
nt
,
openfile
->
placewewa
nt
)
!=
was_chunk
)
{
chunk_
for
(
openfile
->
placewewa
nt
,
openfile
->
curre
nt
)
!=
was_chunk
)
{
edit_scroll
(
DOWNWARD
,
ISSET
(
SMOOTH_SCROLL
)
?
1
:
editwinrows
/
2
+
1
);
return
;
}
...
...
This diff is collapsed.
Click to expand it.
src/nano.c
View file @
fbbf501f
...
...
@@ -1762,7 +1762,7 @@ int do_mouse(void)
/* Whether the click was on the row where the cursor is. */
if
(
ISSET
(
SOFTWRAP
))
leftedge
=
get_chunk_leftedge
(
openfile
->
current
,
xplustabs
()
);
leftedge
=
leftedge_for
(
xplustabs
(),
openfile
->
current
);
else
#endif
leftedge
=
get_page_start
(
xplustabs
());
...
...
@@ -1812,8 +1812,8 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
if
(
ISSET
(
SOFTWRAP
))
{
if
(
openfile
->
current_y
==
editwinrows
-
1
)
original_row
=
get_
chunk_
row
(
openfile
->
current
,
xplustabs
()
);
orig_rows
=
get_last
_chunk
_row
(
openfile
->
current
);
original_row
=
chunk_
for
(
xplustabs
(),
openfile
->
current
);
orig_rows
=
number_of
_chunk
s_in
(
openfile
->
current
);
}
#endif
...
...
@@ -1878,9 +1878,9 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
* of the edit window, and we moved one screen row, we're now below
* the last line of the edit window, so we need a full refresh too. */
if
(
ISSET
(
SOFTWRAP
)
&&
refresh_needed
==
FALSE
&&
(
get_last
_chunk
_row
(
openfile
->
current
)
!=
orig_rows
||
(
number_of
_chunk
s_in
(
openfile
->
current
)
!=
orig_rows
||
(
openfile
->
current_y
==
editwinrows
-
1
&&
get_
chunk_
row
(
openfile
->
current
,
xplustabs
()
)
!=
original_row
)))
chunk_
for
(
xplustabs
(),
openfile
->
current
)
!=
original_row
)))
refresh_needed
=
TRUE
;
#endif
...
...
This diff is collapsed.
Click to expand it.
src/proto.h
View file @
fbbf501f
...
...
@@ -665,10 +665,10 @@ void edit_scroll(scroll_dir direction, int nrows);
#ifndef NANO_TINY
size_t
get_softwrap_breakpoint
(
const
char
*
text
,
size_t
leftedge
,
bool
*
end_of_line
);
size_t
get_chunk
(
filestruct
*
line
,
size_t
column
,
size_t
*
leftedge
);
size_t
get_
chunk_
row
(
filestruct
*
line
,
size_t
column
);
size_t
get_chunk_leftedge
(
filestruct
*
line
,
size_t
column
);
size_t
get_last
_chunk
_row
(
filestruct
*
line
);
size_t
get_chunk
_and_edge
(
size_t
column
,
filestruct
*
line
,
size_t
*
leftedge
);
size_t
chunk_
for
(
size_t
column
,
filestruct
*
line
);
size_t
leftedge_for
(
size_t
column
,
filestruct
*
line
);
size_t
number_of
_chunk
s_in
(
filestruct
*
line
);
void
ensure_firstcolumn_is_aligned
(
void
);
#endif
size_t
actual_last_column
(
size_t
leftedge
,
size_t
column
);
...
...
This diff is collapsed.
Click to expand it.
src/search.c
View file @
fbbf501f
...
...
@@ -900,7 +900,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
#ifndef NANO_TINY
if
(
ISSET
(
SOFTWRAP
))
{
filestruct
*
line
=
openfile
->
current
;
size_t
leftedge
=
get_chunk_leftedge
(
openfile
->
current
,
xplustabs
()
);
size_t
leftedge
=
leftedge_for
(
xplustabs
(),
openfile
->
current
);
rows_from_tail
=
(
editwinrows
/
2
)
-
go_forward_chunks
(
editwinrows
/
2
,
&
line
,
&
leftedge
);
...
...
This diff is collapsed.
Click to expand it.
src/text.c
View file @
fbbf501f
...
...
@@ -112,7 +112,7 @@ void do_deletion(undo_type action)
update_undo
(
action
);
if
(
ISSET
(
SOFTWRAP
))
orig_rows
=
get_last
_chunk
_row
(
openfile
->
current
);
orig_rows
=
number_of
_chunk
s_in
(
openfile
->
current
);
#endif
/* Move the remainder of the line "in", over the current character. */
...
...
@@ -181,7 +181,7 @@ void do_deletion(undo_type action)
/* If the number of screen rows that a softwrapped line occupies
* has changed, we need a full refresh. */
if
(
ISSET
(
SOFTWRAP
)
&&
refresh_needed
==
FALSE
&&
get_last
_chunk
_row
(
openfile
->
current
)
!=
orig_rows
)
number_of
_chunk
s_in
(
openfile
->
current
)
!=
orig_rows
)
refresh_needed
=
TRUE
;
#endif
...
...
This diff is collapsed.
Click to expand it.
src/winio.c
View file @
fbbf501f
...
...
@@ -2296,16 +2296,16 @@ void place_the_cursor(bool forreal)
filestruct
*
line
=
openfile
->
edittop
;
size_t
leftedge
;
row
-=
get_
chunk_
row
(
openfile
->
edittop
,
openfile
->
firstcolumn
);
row
-=
chunk_
for
(
openfile
->
firstcolumn
,
openfile
->
edittop
);
/* Calculate how many rows the lines from edittop to current use. */
while
(
line
!=
NULL
&&
line
!=
openfile
->
current
)
{
row
+=
get_last
_chunk
_row
(
line
)
+
1
;
row
+=
number_of
_chunk
s_in
(
line
)
+
1
;
line
=
line
->
next
;
}
/* Add the number of wraps in the current line before the cursor. */
row
+=
get_chunk
(
openfile
->
current
,
xpt
,
&
leftedge
);
row
+=
get_chunk
_and_edge
(
xpt
,
openfile
->
current
,
&
leftedge
);
col
=
xpt
-
leftedge
;
}
else
#endif
...
...
@@ -2748,11 +2748,11 @@ int update_softwrapped_line(filestruct *fileptr)
if
(
fileptr
==
openfile
->
edittop
)
from_col
=
openfile
->
firstcolumn
;
else
row
-=
get_
chunk_
row
(
openfile
->
edittop
,
openfile
->
firstcolumn
);
row
-=
chunk_
for
(
openfile
->
firstcolumn
,
openfile
->
edittop
);
/* Find out on which screen row the target line should be shown. */
while
(
line
!=
fileptr
&&
line
!=
NULL
)
{
row
+=
get_last
_chunk
_row
(
line
)
+
1
;
row
+=
number_of
_chunk
s_in
(
line
)
+
1
;
line
=
line
->
next
;
}
...
...
@@ -2825,8 +2825,7 @@ int go_back_chunks(int nrows, filestruct **line, size_t *leftedge)
/* Recede through the requested number of chunks. */
for
(
i
=
nrows
;
i
>
0
;
i
--
)
{
if
(
current_leftedge
>
0
)
{
current_leftedge
=
get_chunk_leftedge
(
*
line
,
current_leftedge
-
1
);
current_leftedge
=
leftedge_for
(
current_leftedge
-
1
,
*
line
);
continue
;
}
...
...
@@ -2834,7 +2833,7 @@ int go_back_chunks(int nrows, filestruct **line, size_t *leftedge)
break
;
*
line
=
(
*
line
)
->
prev
;
current_leftedge
=
get_chunk_leftedge
(
*
line
,
(
size_t
)
-
1
);
current_leftedge
=
leftedge_for
(
(
size_t
)
-
1
,
*
line
);
}
/* Only change leftedge when we actually could move. */
...
...
@@ -2900,7 +2899,7 @@ bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge)
#ifndef NANO_TINY
if
(
ISSET
(
SOFTWRAP
))
{
filestruct
*
line
=
openfile
->
current
;
size_t
leftedge
=
get_chunk_leftedge
(
openfile
->
current
,
xplustabs
()
);
size_t
leftedge
=
leftedge_for
(
xplustabs
(),
openfile
->
current
);
int
rows_left
=
go_back_chunks
(
editwinrows
-
1
,
&
line
,
&
leftedge
);
return
(
rows_left
>
0
||
line
->
lineno
<
was_lineno
||
...
...
@@ -2966,11 +2965,11 @@ void edit_scroll(scroll_dir direction, int nrows)
#ifndef NANO_TINY
/* Compensate for the earlier chunks of a softwrapped line. */
nrows
+=
get_
chunk_
row
(
line
,
leftedg
e
);
nrows
+=
chunk_
for
(
leftedge
,
lin
e
);
/* Don't compensate for the chunks that are offscreen. */
if
(
line
==
openfile
->
edittop
)
nrows
-=
get_
chunk_
row
(
line
,
openfile
->
firstcolumn
);
nrows
-=
chunk_
for
(
openfile
->
firstcolumn
,
line
);
#endif
/* Draw new content on the blank rows inside the scrolled region
...
...
@@ -3050,7 +3049,7 @@ size_t get_softwrap_breakpoint(const char *text, size_t leftedge,
/* Get the row of the softwrapped chunk of the given line that column is on,
* relative to the first row (zero-based), and return it. If leftedge isn't
* NULL, return the leftmost column of the chunk in it. */
size_t
get_chunk
(
filestruct
*
line
,
size_t
column
,
size_t
*
leftedge
)
size_t
get_chunk
_and_edge
(
size_t
column
,
filestruct
*
line
,
size_t
*
leftedge
)
{
size_t
current_chunk
=
0
,
start_col
=
0
,
end_col
;
bool
end_of_line
=
FALSE
;
...
...
@@ -3072,27 +3071,27 @@ size_t get_chunk(filestruct *line, size_t column, size_t *leftedge)
/* Return the row of the softwrapped chunk of the given line that column is on,
* relative to the first row (zero-based). */
size_t
get_
chunk_
row
(
filestruct
*
line
,
size_t
column
)
size_t
chunk_
for
(
size_t
column
,
filestruct
*
line
)
{
return
get_chunk
(
line
,
column
,
NULL
);
return
get_chunk
_and_edge
(
column
,
line
,
NULL
);
}
/* Return the leftmost column of the softwrapped chunk of the given line that
* column is on. */
size_t
get_chunk_leftedge
(
filestruct
*
line
,
size_t
column
)
size_t
leftedge_for
(
size_t
column
,
filestruct
*
line
)
{
size_t
leftedge
;
get_chunk
(
line
,
column
,
&
leftedge
);
get_chunk
_and_edge
(
column
,
line
,
&
leftedge
);
return
leftedge
;
}
/* Return the row of the last softwrapped chunk of the given line, relative to
* the first row (zero-based). */
size_t
get_last
_chunk
_row
(
filestruct
*
line
)
size_t
number_of
_chunk
s_in
(
filestruct
*
line
)
{
return
get_
chunk_
row
(
line
,
(
size_t
)
-
1
);
return
chunk_
for
(
(
size_t
)
-
1
,
line
);
}
/* Ensure that firstcolumn is at the starting column of the softwrapped chunk
...
...
@@ -3100,8 +3099,8 @@ size_t get_last_chunk_row(filestruct *line)
* has changed, because then the width of softwrapped chunks has changed. */
void
ensure_firstcolumn_is_aligned
(
void
)
{
openfile
->
firstcolumn
=
get_chunk_
leftedge
(
openfile
->
edittop
,
openfile
->
firstcolumn
);
openfile
->
firstcolumn
=
leftedge
_for
(
openfile
->
firstcolumn
,
openfile
->
edittop
);
/* If smooth scrolling is on, make sure the viewport doesn't center. */
focusing
=
FALSE
;
...
...
@@ -3164,8 +3163,8 @@ bool current_is_below_screen(void)
return
(
go_forward_chunks
(
editwinrows
-
1
,
&
line
,
&
leftedge
)
==
0
&&
(
line
->
lineno
<
openfile
->
current
->
lineno
||
(
line
->
lineno
==
openfile
->
current
->
lineno
&&
leftedge
<
get_chunk_leftedge
(
openfile
->
current
,
xplustabs
()
))));
leftedge
<
leftedge_for
(
xplustabs
()
,
openfile
->
current
))));
}
else
#endif
return
(
openfile
->
current
->
lineno
>=
...
...
@@ -3284,8 +3283,7 @@ void adjust_viewport(update_type manner)
openfile
->
edittop
=
openfile
->
current
;
#ifndef NANO_TINY
if
(
ISSET
(
SOFTWRAP
))
openfile
->
firstcolumn
=
get_chunk_leftedge
(
openfile
->
current
,
xplustabs
());
openfile
->
firstcolumn
=
leftedge_for
(
xplustabs
(),
openfile
->
current
);
#endif
/* Move edittop back goal rows, starting at current[current_x]. */
...
...
@@ -3462,7 +3460,7 @@ void spotlight(bool active, size_t from_col, size_t to_col)
void
spotlight_softwrapped
(
bool
active
,
size_t
from_col
,
size_t
to_col
)
{
ssize_t
row
=
openfile
->
current_y
;
size_t
leftedge
=
get_chunk_leftedge
(
openfile
->
current
,
from_col
);
size_t
leftedge
=
leftedge_for
(
from_col
,
openfile
->
current
);
size_t
break_col
;
bool
end_of_line
=
FALSE
;
char
*
word
;
...
...
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