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

Cannon Os V2 - Another Windowed Os

Started by Grim Reaper, 31 August 2013 - 12:01 AM
Grim Reaper #1
Posted 31 August 2013 - 02:01 AM
Having seen Lyqyd's LydydOS when it came out, I decided that I might as well give a go at creating a windowing OS for Computer Craft. To be completely, honest, it took quite a bit of time and frustration to finally get the buffering of programs down, but almost everything else became a matter of design choice.

Features:
- Windows work from sizes 4 x 1 and up.
- All native programs are supported. Really, anything should work.
- Resizing of windows is possible, but its up to the running program to update the width and height its using to the new values.
- Maximize and close buttons on windows are operational, but the minimize button doesn't do anything yet.
- Windows are draggable.
- Command line script which allows the running of programs as windows.
- Event registry for windows or a default set of events which all windows recieve (timers, rednet messages, etc.) essential for multitasking.
- Minimizing of windows (kind of; you can't get the back unless you do it through code. Will fix this).
- Developer tools for manipulating windows when their programs are being run as a window.
- Resizing of windows via mouse click/dragging.


Planned features:
- Desktop/taskbar program to manage all running windows.

Screenshots
Github

Installation instructions:
  • Create a folder system in the root like the following: /CannonOS/Cannon-OS_V2/src/
  • Inside this 'src' folder, you'll need to create three folders: 'Classes', 'Libraries', and 'Programs'.
  • From there, you can download each of the files by manually going to GitHub and downloading them, or you can use this script to download a file from the repo:
    Spoilerhttp://pastebin.com/vs6vcFvF Some indentation got messed up in the following code, sorry :(/>
    
    local args = { ... }
    local function printUsage()
    	print (fs.getName (shell.getRunningProgram()) .. " <path-in-repo> <path-on-computer>")
    end if #args < 2 then
    	printUsage()
    	return
    end
    local pathInRepo	 = args[1]
    local pathOnComputer = args[2]local baseRepoUrl = "https://raw.github.com/TrystanCannon/Cannon-OS_V2/master/"
    local function downloadFileContentsFromRepo (filePathInRepo)
    	local fileInRepoHandle = http.get (baseRepoUrl .. filePathInRepo)
      
    	if fileInRepoHandle then
    		local fileContents = fileInRepoHandle.readAll()
    		fileInRepoHandle.close()
    	  
    		return fileContents
    	end
    endlocal function saveFile (filePathOnComputer, fileContents)
    	local fileHandle = fs.open (filePathOnComputer, 'w')
      
    	if fileHandle then
    		fileHandle.write (fileContents)
    		fileHandle.close()
    	  
    		return true
    	end
      
    	return false
    end
    local function installFile (filePathInRepo, filePathOnComputer)
    	return saveFile (filePathOnComputer, downloadFileContentsFromRepo (filePathInRepo))
    endif installFile (pathInRepo, pathOnComputer) then
    	print ("File successfully installed.")
    else
    	print ("Installation failed.")
    end
    
  • Once you've got everything in place, you'll need to run the 'Main' script. After this, you simply need to press F1 to start the command line.
  • Running programs is as simple as typing the name of the program (or alias) followed by the width, height, and any arguments you wanted to start the program with.
Edited on 15 November 2013 - 04:44 PM
Zudo #2
Posted 31 August 2013 - 02:54 AM
Click "use full editor" to change the title.
Grim Reaper #3
Posted 31 August 2013 - 01:08 PM
Click "use full editor" to change the title.
Thanks, man.
Kingdaro #4
Posted 01 September 2013 - 02:11 AM
Great work on this! I have a question and a suggestion.
  • I'd drop the borders on windows entirely, and make it so they only have titles/captions or whatever.
  • Where do minimized windows go?
Grim Reaper #5
Posted 01 September 2013 - 11:12 AM
As of right now, the borders are gone (I think it looks cleaner this way. Thanks, Kingdaro) and a program called Task_Manager has been written. Although you can't revive windows through the GUI yet, minimizing them causes them to simply not be drawn and not receive events that they aren't registered for.

Event registry has been added although I kind of already mentioned that in the last sentence :P/>. All windows receive timer events, modem messages, and alarms unless unregistered for those events.
Phil96 #6
Posted 15 September 2013 - 07:51 AM
This OS looks really good, nice work. You should maybe think about removing the shadows, this would cause multitasking to be much more efficient.
Have you been inspired by the old MacOS 6 or 7 versions? Your OS looks a bit like one of them.
Grim Reaper #7
Posted 29 September 2013 - 09:37 PM
This OS looks really good, nice work. You should maybe think about removing the shadows, this would cause multitasking to be much more efficient.
Have you been inspired by the old MacOS 6 or 7 versions? Your OS looks a bit like one of them.

Interestingly enough, the screenshots are a little outdated. The native taskbar program was scrapped and there are no more shadows for windows, although I haven't really noticed much difference in the time it takes to draw the windows. Also, the buffer class was improved, although, again, there hasn't been any noticeable difference in drawing speed.

I've actually never used a computer that has MacOS on it :P/>
Techman749 #8
Posted 03 November 2013 - 01:59 PM
Dude, Great job! I loved the original CannonOS when it came out! Yet, another great program from Grim Reaper!
LemADEC #9
Posted 15 November 2013 - 05:01 PM
How do we download and install it?
Grim Reaper #10
Posted 15 November 2013 - 05:34 PM
Unfortunately, it's a little bit of work. I've added a description to the OP, so you can check it out there! :)/>