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

Multitasking Window API

Started by Jummit, 12 April 2018 - 04:38 PM
Jummit #1
Posted 12 April 2018 - 06:38 PM
This is kind of the advanced version of ShellSplit, my first program that uses coroutines to achieve multitasking. This one is way more complex, featuring movable, resizable windows.
Demo at work:

Download:
API: pastebin get UQM4T3J3 programs.lua
DEMO: pastebin get HiqdSExG demo.lua
To try it out, just download the api and run the demo
Edited on 12 April 2018 - 06:19 PM
CCTech #2
Posted 14 April 2018 - 07:18 PM
nice work ;)/> looks pretty cool.

Would it be ok if I use this in my OS? I surely will credit you
Jummit #3
Posted 14 April 2018 - 07:45 PM
nice work ;)/> looks pretty cool.

Would it be ok if I use this in my OS? I surely will credit you
I actually made this with my coming OS in mind. Sure, give it a go!
<greedy me>
It only costs one upvote!
</greedy me>
Edited on 14 April 2018 - 05:46 PM
CCTech #4
Posted 14 April 2018 - 10:33 PM
<greedy me>
It only costs one upvote!
</greedy me>

Upvote? Sorry i‘m not so often here..
Lupus590 #5
Posted 14 April 2018 - 10:44 PM
Upvote? Sorry i‘m not so often here..

the little green arrow in the bottom right of posts (your posts won't have one as you cannot upvote your own post).
CCTech #6
Posted 14 April 2018 - 10:55 PM
the little green arrow in the bottom right of posts (your posts won't have one as you cannot upvote your own post).

Thanks didn‘t saw it.. it‘s because I‘m using this on phone.. (can‘t access my laptop right now)
Jummit #7
Posted 16 April 2018 - 07:57 AM
A new version is out, now will display on top when selected. The api has not changed, so you can use the code you have made before the change.
minebuild02 #8
Posted 20 June 2018 - 10:11 AM
I would like to try and use it in my new OS that is currently in development.
InFluXx #9
Posted 27 March 2019 - 10:44 PM
May I use this API on the OS I'm working on? I credit you
CCTech #10
Posted 02 April 2019 - 03:05 PM
Well uhm.. I'm not really sure that this is the right place but asking in "Ask a pro" would be not the best choice (I think?)

I tried to add this windows system to my OS and now I stuck at making a window handler.

It kinda works. It draws the windows but… they're black

Here are the codes:

inside the handler

function drawWindows()
  while true do
    local event, var1, var2, var3 = os.pullEventRaw()
    if event == "terminate" then end
    windows.update(kernel.programs, event, var1, var2, var3)
  end
end

And then if a new window is created:

function taskBar()
  windows.new(function()
    shell.run("/PowerOS/sys/taskBar)")
  end, 9, 1, 35, 2)
end
function drawDesktop()
  opscy.drawColor(colors.white)
  table.insert(kernel.programs, taskBar())
end

The window that should appear is black without the topbar (Even if the positions aren't 1,1)

I tried it with some other programs which should run inside the window but with no success…

I have often rewrote the full code

I hope you can help me :P/>
Jummit #11
Posted 03 April 2019 - 06:05 PM
I tried to add this windows system to my OS and now I stuck at making a window handler.

- snip -

I need more of your code to help you. What does windows.update and windows.new do?
CCTech #12
Posted 03 April 2019 - 08:38 PM
I need more of your code to help you. What does windows.update and windows.new do?

Uhh.. it's from your window API i just did


local windows = require(TheApiPath)

instead of


local program = require(TheApiPath)

It was all of my code that I posted which is for handling the Windows
Jummit #13
Posted 03 April 2019 - 08:49 PM
I need more of your code to help you. What does windows.update and windows.new do?

Uhh.. it's from your window API i just did


local windows = require(TheApiPath)

instead of


local program = require(TheApiPath)

It was all of my code that I posted which is for handling the Windows
Oops, I didn't spot that. I havn't worked with this api for quite some time, so I didn't notice.
Your issue is that the taskBar function never returns anything. Here is the fixed code:

function taskBar()
  return windows.new(function()
    shell.run("/PowerOS/sys/taskBar)")
  end, 9, 1, 35, 2)
end
CCTech #14
Posted 04 April 2019 - 05:11 PM
I need more of your code to help you. What does windows.update and windows.new do?
Uhh.. it's from your window API i just did
 local windows = require(TheApiPath) 
instead of
 local program = require(TheApiPath) 
It was all of my code that I posted which is for handling the Windows
Oops, I didn't spot that. I havn't worked with this api for quite some time, so I didn't notice. Your issue is that the taskBar function never returns anything. Here is the fixed code:
 function taskBar() return windows.new(function() shell.run("/PowerOS/sys/taskBar)") end, 9, 1, 35, 2) end 

Oh, indeed! Thanks for the quick support! Didn't thought about that it may needs to return something :P/>
CCTech #15
Posted 05 April 2019 - 05:22 PM
aaand… sorry if I disturb you

I just think that I'm too… well I think you know what I mean..

Is there a way to reparent a window? I have a program that starts other programs but their windows only appear inside the programs window and not as seperate windows.

I also tried making a table and the update function inside the window handler (not your API) checks if it is empty. If not then it should move the window from inside the table inside the right table that contains all windows. Still only inside the window that runs it… So is there any way of "parenting" a window?

Thanks in advance

and: Am I allowed to modify the API a bit to change the window designs? I want to be on the safe side :P/>
CCTech #16
Posted 05 April 2019 - 10:15 PM
Never mind.. got it to Work :P/>