diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/twopane.bash | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/src/twopane.bash b/src/twopane.bash index d49ca4f..f496701 100755 --- a/src/twopane.bash +++ b/src/twopane.bash | |||
@@ -246,7 +246,7 @@ forward() | |||
246 | socat FD:$STDIN,$stty!!STDOUT - <&$stdin >&$TEE 2>&$STDERR & | 246 | socat FD:$STDIN,$stty!!STDOUT - <&$stdin >&$TEE 2>&$STDERR & |
247 | } 2>/dev/null | 247 | } 2>/dev/null |
248 | FORWARD_PID=$! | 248 | FORWARD_PID=$! |
249 | printf '%s\n' "#!/bin/bash" "kill $!" "screen -X focus bottom" > "$TWOPANE"/unforward | 249 | printf '%s\n' "#!/bin/bash" "kill -TSTP $!" "screen -X focus bottom" > "$TWOPANE"/unforward |
250 | chmod +x "$TWOPANE"/unforward | 250 | chmod +x "$TWOPANE"/unforward |
251 | fg >/dev/null | 251 | fg >/dev/null |
252 | stty "$old_stty" | 252 | stty "$old_stty" |
@@ -284,14 +284,47 @@ resume_forward() | |||
284 | focus bottom | 284 | focus bottom |
285 | } | 285 | } |
286 | 286 | ||
287 | tty_forward() | ||
288 | { | ||
289 | read-tty | ||
290 | } | ||
291 | |||
292 | background() | ||
293 | { | ||
294 | old_stty=$(stty -g) | ||
295 | start_screen_pane "$@" | ||
296 | focus bottom | ||
297 | connect stdin stdout | ||
298 | #stty tostop | ||
299 | exec {BOTTOM_PANE}> >(trap 'echo SIG >&2' SIGTTOU SIGTTIN SIGTSTP; output_filter) | ||
300 | BOTTOM_PANE_PID=$! | ||
301 | exec {BOTH_PANES}> >(trap 'echo TTOU >&2' SIGTTOU; ptee 1 $BOTTOM_PANE >&$stdout) | ||
302 | exec {NET_MERGE}> >(exec {STDIN}<&0; exec -a merge_reader socat FD:$STDIN!!STDOUT - <&$stdin >&$BOTH_PANES) | ||
303 | local STDERR | ||
304 | exec {STDERR}>&2 | ||
305 | { | ||
306 | exec 2>&$STDERR {STDERR}>&- | ||
307 | tty_forward & | ||
308 | } >&$NET_MERGE 2>/dev/null | ||
309 | TTY_READER_PID=$! | ||
310 | printf '%s\n' "#!/bin/bash" "kill -TSTP $TTY_READER_PID" "screen -X focus bottom" > "$TWOPANE"/unforward | ||
311 | chmod +x "$TWOPANE"/unforward | ||
312 | #"$TWOPANE"/unforward | ||
313 | } | ||
314 | |||
287 | foreground() | 315 | foreground() |
288 | { | 316 | { |
289 | if forwarding | 317 | if ! jobs -p %tty_forward >/dev/null 2>&1 |
290 | then | 318 | then |
291 | resume_forward | 319 | background |
292 | else | 320 | else |
293 | foreground_loop "$@" | 321 | old_stty=$(stty -g) |
294 | fi | 322 | fi |
323 | cfmakeraw opost onlcr | ||
324 | focus top | ||
325 | fg %tty_forward | ||
326 | stty "$old_stty" | ||
327 | focus bottom | ||
295 | } | 328 | } |
296 | 329 | ||
297 | twopane() | 330 | twopane() |