Jump to content




Tabbed Multitasking Api


2 replies to this topic

#1 AssossaGPB

  • Members
  • 126 posts
  • LocationFlorida, USA

Posted 27 June 2014 - 04:22 PM

A friend was working on his os and asked me to write him a tabbed multitasking api for his os. I figured it couldn't be that hard, so I wrote it. After about 2 weeks of debugging here it is for the community to enjoy. And, yes I know that it is not true multitasking.

Download:
http://pastebin.com/V2pLdrdF
or
pastebin get V2pLdrdF tabmulti

Functions:
newTab(functionName,tabName) - Creates a new tab
setTabName(index,name) - Changes a tab's name at index to name
getTabName(index) - Gets a tab name at index
getTabNames() - Returns a table with all the tab names in their respective locations
getTabs() - Returns a table with all the tab coroutines in their respective locations
getCurrentTab() - Returns the index of the current tab
switchTab(index) - Switches the current tab to index
moveTab(pos1,pos2) - Moves tab at pos1 to pos2
closeTab(index) - Closes tab at index
runTabs() - Runs all the tabs
runCurrentTab() - Runs the current tab and pauses the other tabs
drawTabs() - Draws the tab bar
tabClick() - Checks for clicks on the tab bar and does the respective action (Does not support tab closing or tab moving currently)
tabRun(programName,tabName) - Runs a program in a tab

tabMain is a example main function to run the api, you may use it or write your own.

How to allow your programs/functions to work in the tabs:
In your functions/programs make sure to check is it is the current tab before drawing on the screen or checking for input. The api does not handle this yet, because I can not figure out how. If you do not do this, then all the tabs will be checking for input and drawing to the screen at the same time and it wont be too pretty.

Please point out any typos/bugs/glitches you find, any feedback will be appriciated!

Edited by AssossaGPB, 27 June 2014 - 04:24 PM.


#2 DubbelSoftware

  • Members
  • 62 posts

Posted 10 March 2017 - 05:07 PM

This api does not work for my, i get an error on line 204.

#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 12 March 2017 - 03:54 AM

Assossa hasn't logged in for some time, and this API was written for a much older build of ComputerCraft than those which are current. You're probably better off using shell.openTab() / shell.switchTab() and the associated functions in the multishell API.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users