Advertisement
D_Puppy

terminal.lua

Jul 31st, 2017
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.25 KB | None | 0 0
  1. -- GUI --
  2. local component = require("component")
  3. local gpu = component.gpu
  4. local computer = require("computer")
  5. local event = require("event")
  6. local wm = require("wm")
  7. local gui = require("guiElements")
  8. local printserver = require("printserver")
  9. local networkdriver = require("networkdriver")
  10. local user = require("usermanagement")
  11. local term = require("term")
  12.  
  13. local shell = require("shell")
  14. local text = require("text")
  15. local sh = require("sh")
  16.  
  17.  
  18. local ScreenWidth, screenHeight = gpu.getResolution()
  19.  
  20. local args = { ... }
  21.  
  22. local myID = args[1]
  23.  
  24. -- NOTE: Change to your options
  25. local ProgramName = "Terminal"
  26. local windowWidth = 60
  27. local windowHeight = 20
  28. local windowX = math.floor(ScreenWidth/2) - math.floor(windowWidth/2)
  29. local windowY = math.floor(screenHeight/2) - math.floor(windowHeight/2)
  30.  
  31. --NOTE: Put your gui element here, if you use them global in your program
  32. local window, CloseButton
  33.  
  34. local running = true
  35.  
  36. local function windowCloseCallback(win)
  37.   -- NOTE: Insert your code, that will be execute before closing the window here
  38.  
  39.   if myID > 0 then
  40.     wm.exitProgram(myID)
  41.   end
  42. end
  43.  
  44.  
  45.  
  46. local function windowLowerCallback(win)
  47.   -- NOTE: Insert your code, that will be execute when lowering the window here
  48. end
  49.  
  50.  
  51.  
  52. local function buttonCallback(self, win)
  53.   -- NOTE: Insert your code, that will be execute before closing the window here
  54.  
  55.   running = false
  56.   wm.exitProgram(myID)
  57.   wm.closeWindow(window)
  58. end
  59.  
  60.  
  61. window = wm.newWindow(windowX, windowY, windowWidth, windowHeight, ProgramName)
  62. wm.setOnCloseCallback(window, windowCloseCallback)
  63. wm.setOnLowerCallback(window, windowLowerCallback)
  64. --wm.disableWindowButtons(window, true)
  65. --wm.hideWindow(window, hideWindowFromList)
  66. --wm.setWindowSticky(window, true)
  67.  
  68. terminal = gui.newTerminal(1, 1, windowWidth, windowHeight)
  69. wm.addElement(window, terminal)
  70. terminal.firstCall = true
  71.  
  72. wm.raiseWindow(window)
  73.  
  74.  
  75. --[[
  76. program = assert(loadfile("/bin/component.lua"))
  77. local status, err = pcall(program)
  78. gpu.set(1,1, tostring(status).." ".. tostring(err))
  79.   while running == true do
  80.     if wm.getActiveWindow() == window then                  -- prevent window from updating, if it is not the top windows
  81.     end
  82.   os.sleep(0.000001)
  83.   end
  84. ]]--
  85. --wm.closeWindow(window)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement