projects
/
selector.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e3e48a9
)
Deal properly with no selection, just output nothing.
author
Francois Fleuret
<francois@fleuret.org>
Fri, 13 Mar 2009 07:10:06 +0000
(08:10 +0100)
committer
Francois Fleuret
<francois@fleuret.org>
Fri, 13 Mar 2009 07:10:06 +0000
(08:10 +0100)
selector.cc
patch
|
blob
|
history
diff --git
a/selector.cc
b/selector.cc
index
0f71d64
..
56b5b2a
100644
(file)
--- a/
selector.cc
+++ b/
selector.cc
@@
-279,12
+279,13
@@
void update_screen(int *current_line, int *temporary_line, int motion,
}
}
}
}
- *temporary_line = new_line;
if(motion != 0) {
*current_line = new_line;
}
}
if(motion != 0) {
*current_line = new_line;
}
}
+ *temporary_line = new_line;
+
if(nb_printed_lines == 1) {
addnstr("[no selection]\n", console_width);
nb_printed_lines++;
if(nb_printed_lines == 1) {
addnstr("[no selection]\n", console_width);
nb_printed_lines++;
@@
-527,16
+528,22
@@
int main(int argc, char **argv) {
curs_set(1);
endwin();
curs_set(1);
endwin();
- if((key == KEY_ENTER || key == '\n')
&& temporary_line >= 0 && temporary_line < nb_lines
) {
+ if((key == KEY_ENTER || key == '\n')) {
if(output_to_vt_buffer) {
if(output_to_vt_buffer) {
- inject_into_tty_buffer(lines[temporary_line]);
+ if(temporary_line >= 0 && temporary_line < nb_lines) {
+ inject_into_tty_buffer(lines[temporary_line]);
+ }
} else {
ofstream out(output_filename);
if(out.fail()) {
cerr << "Can not open " << output_filename << " for writing." << endl;
exit(1);
} else {
} else {
ofstream out(output_filename);
if(out.fail()) {
cerr << "Can not open " << output_filename << " for writing." << endl;
exit(1);
} else {
- out << lines[temporary_line] << endl;
+ if(temporary_line >= 0 && temporary_line < nb_lines) {
+ out << lines[temporary_line] << endl;
+ } else {
+ out << endl;
+ }
}
out.flush();
}
}
out.flush();
}