//////////////////////////////////////////////////////////////////////
-// This looks severly Linux-only ...
+// This looks severely Linux-only ...
void inject_into_tty_buffer(char *line) {
char *tty = ttyname(STDIN_FILENO);
}
}
- *temporary_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++;
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) {
- 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 {
- out << lines[temporary_line] << endl;
+ if(temporary_line >= 0 && temporary_line < nb_lines) {
+ out << lines[temporary_line] << endl;
+ } else {
+ out << endl;
+ }
}
out.flush();
}