5bitesofcookies

Nocolor - Fix

Mar 5th, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.27 KB | None | 0 0
  1. --CONFIG:
  2. --remove 1 - to disable mutlishell
  3. ---[[
  4. useMultishell = true
  5. --]]
  6. if term.noColorVersion then
  7.     return
  8. end
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20. term.redirect(term.native())
  21. local mShell = multishell
  22. local oShell = shell
  23. multishell = nil
  24. shell = nil
  25. print(multishell)
  26. print(shell)
  27. --load redirect
  28. os.loadAPI"redirect"
  29. --m,ake a new buffer
  30. local w,h = term.getSize()
  31. local ter = redirect.createRedirectBuffer(w,h,0,0,true)
  32.  
  33.  
  34. local w,h = term.getSize()
  35. local bb = false
  36. local tb = false
  37. local bw = false
  38. local tw = false
  39.  
  40. local setTextColor = ter.setTextColor
  41. local setBackgroundColor = ter.setBackgroundColor
  42.  
  43. function term.isColor()
  44.     return true
  45. end
  46.  
  47. function term.isColour()
  48.     return true
  49. end
  50.  
  51. function term.setTextColor(c)
  52.     --[[if c ~= colors.white and c ~= colors.black then
  53.         c = colors.white
  54.     end
  55.  
  56.     if bb == true then
  57.         c = colors.white
  58.     end
  59.  
  60.     if bw == true then
  61.         c = colors.black
  62.     end
  63.  
  64.     if c == colors.black then
  65.         tb = true
  66.     else
  67.         tb = false
  68.     end
  69.  
  70.     if c == colors.white then
  71.         tw = true
  72.     else
  73.         tw = false
  74.     end
  75. ]]
  76.     return setTextColor(colors.white)
  77. end
  78. --local bb = false
  79.  
  80. function term.setBackgroundColor(c)
  81.     --[[if c ~= colors.white and c ~= colors.black then
  82.         c = colors.black
  83.     end
  84.  
  85.     if c == colors.black then
  86.         bb = true
  87.     else
  88.         bb = false
  89.     end
  90.  
  91.     if c == colors.white then
  92.         bw = true
  93.     else
  94.         bw = false
  95.     end
  96.  
  97.     if tb == true then
  98.         c = colors.white
  99.     end
  100.  
  101.     if tw == true then
  102.         c = colors.black
  103.     end
  104. ]]
  105.     return setBackgroundColor(colors.black)
  106. end
  107.  
  108. ter.setTextColour = ter.setTextColor
  109. ter.setBackgroundColour = ter.setBackgroundColor
  110.  
  111. function term.usingNoColor()
  112.     return true
  113. end
  114.  
  115. ter.usingNoColour = ter.usingNoColor
  116. UsingNoColor = ter.usingNoColor
  117. UsingNoColour = ter.usingNoColor
  118.  
  119. function term.noColorVersion()
  120.     return "v1-M"--version 1 modded
  121. end
  122.  
  123.  
  124. ter.noColourVersion = ter.noColorVersion
  125. NoColourVersion = ter.noColorVersion
  126. NoColorVersion = ter.noColorVersion
  127. --function ter.native() return ter end
  128. local native = term.current()
  129. --ter = term.current()
  130. term.clear()
  131. ter.makeActive(1,1)
  132. term.redirect(ter)
  133. term.clear()
  134. term.setCursorPos(1,1)
  135. --[[code:
  136. 1 - started mousepress
  137. table -- returning event
  138. 2 - user wants 'alt']]
  139. local shellCo = coroutine.create(function()
  140.     if useMultishell then
  141.         os.run({},"rom/programs/advanced/multishell")
  142.     else
  143.         os.run({},"rom/programs/shell")
  144.     end
  145. end)
  146. --[[mouse = coroutine.create(function()
  147.     local inform
  148.     local x
  149.     local y
  150.     local w,h = term.getSize()
  151.     while true do
  152.         local a={coroutine.yield(inform)}
  153.  
  154.         end
  155.     end
  156. end)]]
  157. os.queueEvent"ignoreThis"
  158. function p(a,b,c,d,e,f,g) if false then write(a or ""..b or ""..c or ""..d or ""..e or ""..f or ""..g or "") end end
  159. local nextEvent
  160. local x,y = 1,1
  161. while coroutine.status(shellCo)=="suspended" do
  162.     --print"1"
  163.     local a
  164.     if nextEvent then
  165.         --p(nextEvent)
  166.         --sleep(1)
  167.         a = nextEvent
  168.     else
  169.         a = {coroutine.yield()}
  170.     end
  171.     --print"2"
  172.     --print"2.5"
  173.     nextEvent = nil
  174.     --nextEvent things:
  175.     if a[1] =="key" and a[2]==56 then --alt
  176.         local px,py = term.getCursorPos()--cursor pos before moving
  177.         term.setCursorBlink(false)
  178.         term.setBackgroundColor(colors.black)
  179.         term.redirect(native)
  180.         term.setTextColor(colors.white)
  181.         term.setCursorPos(x,y)
  182.         write"X"
  183.         while true do
  184.             local a = {coroutine.yield()}
  185.             if a[1]=="key" then
  186.                 if a[2]==200 then --up
  187.                     if not (y<=1) then
  188.                         y=y-1
  189.                     end
  190.                 elseif a[2]==208  then --down
  191.                     if not (y>=h) then
  192.                         y=y+1
  193.                     end
  194.                 elseif a[2]==203 then  --left
  195.                     if not (x<=1) then
  196.                         x=x-1
  197.                     end
  198.                 elseif a[2]==205 then --right
  199.                     if not (x>=w) then
  200.                         x=x+1
  201.                     end
  202.                 elseif a[2]==56 then
  203.                     nextEvent = {"key",56}--alt
  204.                     break
  205.                 elseif a[2]==28 then --enter
  206.                     nextEvent ={"mouse_click",1,x,y}--m1 at x,y
  207.                     break
  208.                 elseif a[2]==54 then --shift
  209.                     nextEvent = {"mouse_click",2,x,y}--m2 at x,y
  210.                     break
  211.                 end
  212.             end
  213.             --draw it
  214.             --term.redirect(native)
  215.             ter.blit()--draw the screen
  216.             p(x,y)
  217.             term.setCursorPos(x,y)
  218.             write"X"
  219.         end
  220.         --ter.blit()
  221.         term.setCursorPos(px,py)
  222.     else
  223.         term.redirect(ter)
  224.         coroutine.resume(shellCo,unpack(a))
  225.     end
  226.     --term.redirect(native)
  227.     --ter.blit()
  228. end
  229. term.redirect(native)
  230. print"Completed."
  231. multishell = mShell
  232. shell = oShell
Advertisement
Add Comment
Please, Sign In to add comment