Skip to content

Commit 4611514

Browse files
author
Yorhel
committed
Add --no-bracketed-paste option
1 parent 0f20968 commit 4611514

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

doc/ncdc.pod.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ Display summary of options.
8181

8282
Don't automatically connect to hubs with the C<autoconnect> option set.
8383

84+
=item B<--no-bracketed-paste>
85+
86+
Disable bracketed pasting.
87+
8488
=item B<-v, --version>
8589

8690
Display ncdc version.

src/main.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ static gboolean print_version(const gchar *name, const gchar *val, gpointer dat,
359359

360360

361361
static gboolean auto_open = TRUE;
362+
static gboolean bracketed_paste = TRUE;
362363

363364
static GOptionEntry cli_options[] = {
364365
{ "version", 'v', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, print_version,
@@ -367,6 +368,8 @@ static GOptionEntry cli_options[] = {
367368
"Use a different session directory. Default: `$NCDC_DIR' or `$HOME/.ncdc'.", "<dir>" },
368369
{ "no-autoconnect", 'n', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &auto_open,
369370
"Don't automatically connect to hubs with the `autoconnect' option set.", NULL },
371+
{ "no-bracketed-paste", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &bracketed_paste,
372+
"Disable bracketed pasting.", NULL },
370373
{ NULL }
371374
};
372375

@@ -449,7 +452,7 @@ int main(int argc, char **argv) {
449452
cc_global_init();
450453
dl_init_global();
451454
ui_cmdhist_init("history");
452-
ui_init();
455+
ui_init(bracketed_paste);
453456

454457
// setup SIGWINCH
455458
struct sigaction act;
@@ -505,7 +508,8 @@ int main(int argc, char **argv) {
505508
erase();
506509
refresh();
507510
endwin();
508-
ui_set_bracketed_paste(0);
511+
if(bracketed_paste)
512+
ui_set_bracketed_paste(0);
509513

510514
printf("Flushing unsaved data to disk...");
511515
fflush(stdout);

src/ui.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ void ui_set_bracketed_paste(int enable) {
260260
}
261261

262262

263-
void ui_init() {
263+
void ui_init(gboolean bracketed_paste) {
264264
// init curses
265265
initscr();
266266
raw();
@@ -270,9 +270,11 @@ void ui_init() {
270270
nodelay(stdscr, 1);
271271

272272
// ensure curses is init'd before event-keys defined before events happen
273-
define_key("\x1b[200~", KEY_BRACKETED_PASTE_START);
274-
define_key("\x1b[201~", KEY_BRACKETED_PASTE_END);
275-
ui_set_bracketed_paste(1);
273+
if(bracketed_paste) {
274+
define_key("\x1b[200~", KEY_BRACKETED_PASTE_START);
275+
define_key("\x1b[201~", KEY_BRACKETED_PASTE_END);
276+
ui_set_bracketed_paste(1);
277+
}
276278

277279
// global textinput field
278280
ui_global_textinput = ui_textinput_create(TRUE, cmd_suggest);
@@ -281,8 +283,6 @@ void ui_init() {
281283
ui_tab_open(uit_main_create(), TRUE, NULL);
282284

283285
ui_colors_init();
284-
285-
// draw
286286
ui_draw();
287287
}
288288

0 commit comments

Comments
 (0)