Skip to content

Commit

Permalink
FIX: Skip bracketed paste mode initialization on POSIX when using `--…
Browse files Browse the repository at this point in the history
…cgi` flag
  • Loading branch information
Oldes committed Jan 29, 2025
1 parent 1470fdf commit 7db98cd
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/include/reb-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
** REBOL [R3] Language Interpreter and Run-time Environment
**
** Copyright 2012 REBOL Technologies
** Copyright 2013-2024 Rebol Open Source Developers
** Copyright 2013-2025 Rebol Open Source Developers
** REBOL is a trademark of REBOL Technologies
**
** Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -118,7 +118,8 @@ enum {

enum {
RDM_NULL, // Null device
RDM_READ_LINE,
RDM_READ_LINE, // Read line mode
RDM_CGI
};

// Serial Parity
Expand Down
3 changes: 1 addition & 2 deletions src/mezz/mezz-help.reb
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ import (module [
^[[1;32m--secure policy^[[m Can be: none allow ask throw quit
^[[1;32m--trace (-t)^[[m Enable trace mode during boot
^[[1;32m--verbose^[[m Show detailed startup information
^[[1;32m--cgi (-c)^[[m Starts in a CGI mode
^[[4;1;36mOther quick options^[[m:
Expand All @@ -510,8 +511,6 @@ import (module [
REBOL -s script.r
REBOL script.r 10:30 test@example.com
REBOL --do "watch: on" script.r}

; --cgi (-c) Load CGI utiliy module and modes
]


Expand Down
4 changes: 2 additions & 2 deletions src/os/host-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
** REBOL [R3] Language Interpreter and Run-time Environment
**
** Copyright 2012 REBOL Technologies
** Copyright 2021-2023 Rebol Open Source Developers
** Copyright 2021-2025 Rebol Open Source Developers
** REBOL is a trademark of REBOL Technologies
**
** Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -349,7 +349,7 @@ int main(int argc, char **argv) {

Parse_Args(argc, (REBCHR **)argv, &Main_Args);

cgi = Main_Args.options & RO_CGI;
cgi = RO_CGI == (Main_Args.options & RO_CGI);

// Must be done before an console I/O can occur. Does not use reb-lib,
// so this device should open even if there are other problems.
Expand Down
6 changes: 4 additions & 2 deletions src/os/host-stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
** REBOL [R3] Language Interpreter and Run-time Environment
**
** Copyright 2012 REBOL Technologies
** Copyright 2021-2023 Rebol Open Source Developers
** Copyright 2021-2025 Rebol Open Source Developers
** REBOL is a trademark of REBOL Technologies
**
** Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -128,7 +128,9 @@ static int Fetch_Buf()

inbuf = OS_Make(inbuf_len);
inbuf[0] = 0;
if (!cgi)
if (cgi)
SET_FLAG(Std_IO_Req.modes, RDM_CGI);
else
SET_FLAG(Std_IO_Req.modes, RDM_READ_LINE);
return &Std_IO_Req;
}
Expand Down
13 changes: 9 additions & 4 deletions src/os/posix/dev-stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
** REBOL [R3] Language Interpreter and Run-time Environment
**
** Copyright 2012 REBOL Technologies
** Copyright 2012-2025 Rebol Open Source Developers
** REBOL is a trademark of REBOL Technologies
**
** Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -579,8 +580,10 @@ static void Close_StdIO_Local(void)

tcsetattr(Std_Inp, TCSANOW, &original_settings);

// Turn off bracketed paste - https://cirw.in/blog/bracketed-paste
printf("\e[?2004l");
if(!GET_FLAG(req->modes, RDM_CGI)) {
// Turn off bracketed paste - https://cirw.in/blog/bracketed-paste
printf("\e[?2004l");
}
}
else {
//printf("char inp %s\n", dev->title);
Expand All @@ -593,8 +596,10 @@ static void Close_StdIO_Local(void)
//flags |= O_NONBLOCK;
tcsetattr(Std_Inp, TCSANOW, &settings);

// Turn on bracketed paste - https://cirw.in/blog/bracketed-paste
printf("\e[?2004h");
if(!GET_FLAG(req->modes, RDM_CGI)) {
// Turn on bracketed paste - https://cirw.in/blog/bracketed-paste
printf("\e[?2004h");
}
}
//fcntl(Std_Inp, F_SETFL, flags);

Expand Down

0 comments on commit 7db98cd

Please sign in to comment.