summaryrefslogtreecommitdiff
path: root/src/twopane.bash
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2024-08-20 07:14:23 -0400
committerAndrew Cady <d@jerkface.net>2024-08-20 07:14:23 -0400
commitbd3d815e9c3757414b50225ba2c427ab8ff298e7 (patch)
treee92bf116742c47da3805c92f263607b018153020 /src/twopane.bash
parent8c9e4d71a959f131c724e092aefe300c683fbc1b (diff)
"new" backgrounding code
Diffstat (limited to 'src/twopane.bash')
-rwxr-xr-xsrc/twopane.bash41
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
287tty_forward()
288{
289 read-tty
290}
291
292background()
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
287foreground() 315foreground()
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
297twopane() 330twopane()