This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Jummit's profile picture

ShellSplit

Started by Jummit, 11 April 2018 - 09:26 AM
Jummit #1
Posted 11 April 2018 - 11:26 AM
This is a small program I made to learn how to multitask. It allows you to split the shell into two horizontally or vertically.


You can not jet close a splited window, simply rebooting (ctrl-r) will fix it.

Download: pastebin get 7pF6tpZ3 split
Usage: split [horizontal/vertical] [program name]
you can also use 1 instead of horizontal and 2 instead of vertical

also, i got a funny imgur id: https://imgur.com/a/bru0S
Edited on 11 April 2018 - 12:09 PM
SquidDev #2
Posted 11 April 2018 - 11:29 AM
The screenshot looks good - reminds me a little bit of i3 (or Emacs's buffers).

It appears the OP is missing a download link - just wondering where one may find the source, I couldn't see it on GitHub either.
Edited on 11 April 2018 - 09:29 AM
Jummit #3
Posted 11 April 2018 - 11:30 AM
The screenshot looks good - reminds me a little bit of i3 (or Emacs's buffers).

It appears the OP is missing a download link - just wondering where one may find the source, I couldn't see it on GitHub either.
Its just you being a quicky, and me being someone who always edits the post like four times. :D/>
Edited on 11 April 2018 - 09:30 AM
SquidDev #4
Posted 11 April 2018 - 11:34 AM
Its just you being a quicky, and me being someone who always edits the post like four times. :D/>
Sorry! One minor improvement I'd suggest is passing the event to both processes except in a couple of cases (key, key_up, paste, char, terminate, mouse events). This way timers and modem messages will still be processed, but user interaction will not. I see you currently whitelist timers, but it'd probably be better to blacklist the above events instead.

I'd also suggest using table.pack(os.pullEventRaw()) and table.unpack(event, 1, event.n) instead, as these are a little bit more fool-proof when it comes to nil values in events.
Edited on 11 April 2018 - 09:35 AM
Jummit #5
Posted 11 April 2018 - 11:48 AM
Its just you being a quicky, and me being someone who always edits the post like four times. :D/>
Sorry! One minor improvement I'd suggest is passing the event to both processes except in a couple of cases (key, key_up, paste, char, terminate, mouse events). This way timers and modem messages will still be processed, but user interaction will not. I see you currently whitelist timers, but it'd probably be better to blacklist the above events instead.
I give timer events to all programs, but i didn't thought about the other events the user does not generate.
Its just you being a quicky, and me being someone who always edits the post like four times. :D/>
I'd also suggest using table.pack(os.pullEventRaw()) and table.unpack(event, 1, event.n) instead, as these are a little bit more fool-proof when it comes to nil values in events.
The code is really crappy, I just wanted to finish it after the frustrating progress of learning how to use coroutines in cc. :blink:/>
Edited on 11 April 2018 - 09:51 AM
Jummit #6
Posted 11 April 2018 - 12:01 PM
You can not jet close a splited window, simply rebooting (ctrl-r) will fix it.
If a coroutine/program is quit/closed the program will exit instead of freeze.
Jummit #7
Posted 11 April 2018 - 02:09 PM
Oh I really start to love this program:

Fun idea: play worm in such a small window.
Edited on 11 April 2018 - 12:11 PM
Lupus590 #8
Posted 11 April 2018 - 02:33 PM
Off topic:
I'd also suggest using table.pack(os.pullEventRaw()) and table.unpack(event, 1, event.n)…

Should I avoid {os.pullEventRaw()} then?
SquidDev #9
Posted 11 April 2018 - 02:35 PM
Should I avoid {os.pullEventRaw()} then?
Yep! This PR which fixed CC's behaviour explains the rationale behind it, as well as providing some neat examples of how you should handle it.
CrazedProgrammer #10
Posted 11 April 2018 - 02:56 PM
This is extremely cool and definitely something that fills the gap of a window manager in CC!
I have one little issue and that has to deal with the cursor, here's an example: https://i.crzd.me/9K7aS4qR.mp4

It seems like the cursor gets stuck at (0, 0), and if i close split it goes back to normal.
Jummit #11
Posted 11 April 2018 - 03:26 PM
This is extremely cool and definitely something that fills the gap of a window manager in CC!
Thanks! I didn't expect this to turn out so well, like I said, it is just a program I made to learn coroutines.
I have one little issue and that has to deal with the cursor, here's an example: https://i.crzd.me/9K7aS4qR.mp4

It seems like the cursor gets stuck at (0, 0), and if i close split it goes back to normal.
I think I know where this comes from; the blinking cursor can only be displayed on one terminal object. So having multiple terminals with term.setCursorBlink(true) only displays one cursor.
Jummit #12
Posted 12 April 2018 - 07:59 AM
This is extremely cool and definitely something that fills the gap of a window manager in CC!
Thanks! I didn't expect this to turn out so well, like I said, it is just a program I made to learn coroutines.
I have one little issue and that has to deal with the cursor, here's an example: https://i.crzd.me/9K7aS4qR.mp4

It seems like the cursor gets stuck at (0, 0), and if i close split it goes back to normal.
I think I know where this comes from; the blinking cursor can only be displayed on one terminal object. So having multiple terminals with term.setCursorBlink(true) only displays one cursor.
I fixed it, now the cursor is at the position the program wants it to be, and the cursor is shown on the program that is selected.
Lupus590 #13
Posted 12 April 2018 - 10:58 AM
imgur link is borked.
minebuild02 #14
Posted 20 June 2018 - 10:49 AM
Can I use ShellSplit in my new OS as a primitive window manager?
Jummit #15
Posted 21 June 2018 - 08:38 PM
Can I use ShellSplit in my new OS as a primitive window manager?
Its just a program, and you can use it in your OS if you want. There is a new window manager I made here, if you want to take a look at it.

EDIT: I saw you posted there already.
Edited on 21 June 2018 - 06:39 PM