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

NoColor -- Force programs with color!

Started by biggest yikes, 14 February 2015 - 10:00 PM
biggest yikes #1
Posted 14 February 2015 - 11:00 PM
Most people know how a program would crash if it used color on a no-color computer. I have a simple fix for this. I call it NoColor.

What does it do?
Basically, NoColor converts colors to a convenient (usually, sometimes not with operating systems) layout (black background, white text). If the layout already uses black and white, it won't be modified. It's intended to unlock colored programs on non-colored computers, by converting colors to black-and-white.

Installation
It's simple; Type this into your shell.
pastebin run Rmw04i1i
It'll install the program (from github) then reboot the computer.

Screenshots (slightly outdated)
SpoilerOneOS with NoColor (http://www.computerc...erating-system/, taken in v1.2)
Operating systems don't work well with NoColor's style, but you can modify your program to restrict usage of NoColor on it, if you really want to do that.

The Shell (yes, the startup program is NoColor, taken in v1.2)

"Yet Another 2048" with NoColor (http://www.computerc...t-another-2048/, taken in v1.2)

NoColor Test, using the NoColor Developer API (taken in v1.41)

TwoOS in NoColor (Looks nicer than you expected, doesn't it? http://www.computerc...version-is-out/, taken in v1.42, but TwoOS seems to conflict with NoColor and make it look like v1.1 instead because TwoOS uses the "UsingNoColor" function too)

Ultimate Door Lock's PDA with NoColor (taken in v1.42)

Developers
If you're a developer, there's a feature in this program that allows you to detect if the user is using NoColor. It's simple.

if term.usingNoColor then
  --do stuff when using NoColor
end
or

if term.usingNoColour then
  --do stuff when using NoColour
end

You can also check the version of NoColor with term.noColorVersion() and term.noColourVersion(), but only use these functions when you're sure the user is using NoColor v1.4+ (just check if term.noColorVersion exists), or computers that aren't using NoColor will crash when they reach that line.
Any missing documentation can be found here.

Changelog
SpoilerChangelog can also be found here, but only for v1.41+.
v1.52 -Fix bug with startup running twice when updating
v1.51 -Added auto-updater.
v1.5 -Removed api calls that precede with term., as they were subject to conflict.
v1.42 -Old startup file is run after installation & github installer
v1.41 -Removed extraneous spaces in code
v1.4 -Added term.noColo(u)rVersion and NoColo(u)rVersion
v1.3 -Made code smaller and fixed background and text being the same color
v1.2 -Added support for the use of UsingNoColo(u)r instead of term.usingNoColo(u)r
v1.1 -Changed testing format to term.usingNoColo(u)r
v1.0 -Initial Release

Miscellaneous Notes
-This program works on advanced and non-colored computers.
-You can use "UsingNoColo(u)r" instead of "term.usingNoColo(u)r", as of v1.2. v1.0 has "UsingNoColo(u)r", but not "term.usingNoColo(u)r", and v1.1 has only "term.usingNoColo(u)r" but not "UsingNoColo(u)r". Check for UsingNoColo(u)r and term.usingNoColo(u)r with the "or" keyword if you want to check for older versions aswell. As of v1.5, api calls that don't contain term. in them are removed.
-As of v1.4, you can check what version of NoColor the user is using with term.noColo(u)rVersion, yet you cannot check the user's version if they are using v1.3, v1.2, v1.1, or v1.0. (while technically you can distinguish v1.1 with v1.0, you can't distinguish v1.2 with v1.3 without checking the startup file itself for code differences.)
-You can check NoColor out on github here.

If you find any glitches or want to provide feedback, feel free to comment on this post; all feedback, negative or positive, is appreciated.
Edited on 10 May 2015 - 11:40 PM
Geforce Fan #2
Posted 15 February 2015 - 06:00 AM
This has been needed for awhile
Here's a suggestion: to emulate a mouse, perhaps you could press a key, then it have a blinking cursor you could move the arrow keys to where you wanted to click, then press a key to click, or another key to right click? This would allow (almost) full color terminal emulation!
Edited on 15 February 2015 - 05:00 AM
oeed #3
Posted 15 February 2015 - 06:06 AM
This is quite a good idea, I agree with Geforce Fan, a cursor would also be a good idea.
ByteMe #4
Posted 15 February 2015 - 08:51 AM
Hmmm, probably very hard but if possible, take a game like Nightfall by awsumben13 would it be possible to translate the graphics, i.e the pixels that make up the models into their ASCII? for example if you go edit "image_name" instead of paint "image_name" you get random letters that represent the colours, if you could utilise that you could become very close to full terminal emulation.
biggest yikes #5
Posted 15 February 2015 - 02:56 PM
This has been needed for awhile
Here's a suggestion: to emulate a mouse, perhaps you could press a key, then it have a blinking cursor you could move the arrow keys to where you wanted to click, then press a key to click, or another key to right click? This would allow (almost) full color terminal emulation!
Well, I'm really not sure what that has anything to do with coloring, and I'm not sure why one would need that, but I guess it's plausible
Hmmm, probably very hard but if possible, take a game like Nightfall by awsumben13 would it be possible to translate the graphics, i.e the pixels that make up the models into their ASCII? for example if you go edit "image_name" instead of paint "image_name" you get random letters that represent the colours, if you could utilise that you could become very close to full terminal emulation.
If you mean like, the letters in paint, like red is "3", etc. you could just edit the built in textutils function (and the background colors, I suppose), that's a great idea
Edited on 15 February 2015 - 03:34 PM
TheOddByte #6
Posted 15 February 2015 - 05:38 PM
Quite is quite good, it feels like you could shorten the code a bit though
SpoilerInstead of doing this

term.setTextColor = function( c )
    ...
end

term.setTextColour = function( c )
    ...
end
You could just do this, as the functions do the same thing

term.setTextColor = function( c )
    ...
end
term.setTextColour = term.setTextColor
biggest yikes #7
Posted 15 February 2015 - 06:15 PM
Quite is quite good, it feels like you could shorten the code a bit though
SpoilerInstead of doing this

term.setTextColor = function( c )
	...
end

term.setTextColour = function( c )
	...
end
You could just do this, as the functions do the same thing

term.setTextColor = function( c )
	...
end
term.setTextColour = term.setTextColor
oh, good point, never thought of that, I'm super forgetful :P/>
Edited on 15 February 2015 - 05:17 PM
TheOddByte #8
Posted 15 February 2015 - 09:31 PM
So I just tested this on Quest, which seemed to work just fine, but then I noticed that when trying to use the textbox the text color would also be black( the same as the background ), I'd suggest you added support so that text that's on a black "pixel" would have a white color.
biggest yikes #9
Posted 15 February 2015 - 09:37 PM
So I just tested this on Quest, which seemed to work just fine, but then I noticed that when trying to use the textbox the text color would also be black( the same as the background ), I'd suggest you added support so that text that's on a black "pixel" would have a white color.
Good idea.
EDIT: Done. The way I did it (variables) isn't the most efficient way to do it, but it works, so I'm happy.
Edited on 15 February 2015 - 09:09 PM
biggest yikes #10
Posted 01 March 2015 - 10:29 PM
Updated a little, including a new sort of "github installer".
Geforce Fan #11
Posted 02 March 2015 - 01:44 AM
I modified this to enable use of the cursor – basically, you press ALT to spawn the cursor, and use the arrow keys to move it arround. Press ALT again to actually make the program register the press of "alt", ENTER to left-click at that spot, and SHIFT to right-click at that spot. You may use this code, but it requires redirect(an ancient API that I'm probably the last still using) which you can get with:
pastebin get fU9Kj9zr redirect (gopher's API topic found here)
Then
pastebin get HsKus2Nh startup
Here's the code itself (already out of date)
Non-updated code(use pastebin)
--CONFIG:
--remove 1 - to disable mutlishell
---[[
useMultishell = true
--]]













term.redirect(term.native())
local mShell = multishell
local oShell = shell
multishell = nil
shell = nil
print(multishell)
print(shell)
--load redirect
os.loadAPI"redirect"
--m,ake a new buffer
local w,h = term.getSize()
ter = redirect.createRedirectBuffer(w,h,0,0,true)


local w,h = term.getSize()
local bb = false
local tb = false
local bw = false
local tw = false

local setTextColor = ter.setTextColor
local setBackgroundColor = ter.setBackgroundColor

function term.isColor()
	return true
end

function term.isColour()
	return true
end

function term.setTextColor(c)
	if c ~= colors.white and c ~= colors.black then
		c = colors.white
	end
	
	if bb == true then
		c = colors.white
	end
	
	if bw == true then
		c = colors.black
	end
	
	if c == colors.black then
		tb = true
	else
		tb = false
	end
	
	if c == colors.white then
		tw = true
	else
		tw = false
	end
	
	return setTextColor(c)
end
--local bb = false

function term.setBackgroundColor(c)
	if c ~= colors.white and c ~= colors.black then
		c = colors.black
	end
	
	if c == colors.black then
		bb = true
	else
		bb = false
	end
	
	if c == colors.white then
		bw = true
	else
		bw = false
	end
	
	if tb == true then
		c = colors.white
	end
	
	if tw == true then
		c = colors.black
	end
	
	return setBackgroundColor(c)
end

ter.setTextColour = ter.setTextColor
ter.setBackgroundColour = ter.setBackgroundColor

function term.usingNoColor()
	return true
end

ter.usingNoColour = ter.usingNoColor
UsingNoColor = ter.usingNoColor
UsingNoColour = ter.usingNoColor

function term.noColorVersion()
	return "v1-M"--version 1 modded
end


ter.noColourVersion = ter.noColorVersion
NoColourVersion = ter.noColorVersion
NoColorVersion = ter.noColorVersion
--function ter.native() return ter end
local native = term.current()
--ter = term.current()
term.clear()
term.redirect(ter)
term.clear()
term.setCursorPos(1,1)
--[[code:
1 - started mousepress
table -- returning event
2 - user wants 'alt']]
shellCo = coroutine.create(function()
	if useMultishell then
		os.run({},"rom/programs/advanced/multishell")
	else
		os.run({},"rom/programs/shell")
	end
end)
--[[mouse = coroutine.create(function()
	local inform
	local x
	local y
	local w,h = term.getSize()
	while true do
		local a={coroutine.yield(inform)}

		end
	end
end)]]
os.queueEvent"ignoreThis"
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
local nextEvent
local x,y = 1,1
while coroutine.status(shellCo)=="suspended" do
	--print"1"
	local a
	if nextEvent then
		--p(nextEvent)
		--sleep(1)
		a = nextEvent
	else
		a = {coroutine.yield()}
	end
	--print"2"
	--print"2.5"
	nextEvent = nil
	--nextEvent things:
	if a[1] =="key" and a[2]==56 then --alt
		local px,py = term.getCursorPos()--cursor pos before moving
		term.setCursorBlink(false)
		term.setBackgroundColor(colors.black)
		term.redirect(native)
		term.setTextColor(colors.white)
		term.setCursorPos(x,y)
		write"X"
		while true do
			local a = {coroutine.yield()}
			if a[1]=="key" then
				if a[2]==200 then --up
					if not (y<=1) then
						y=y-1
					end
				elseif a[2]==208  then --down
					if not (y>=h) then
						y=y+1
					end
				elseif a[2]==203 then  --left
					if not (x<=1) then
						x=x-1
					end
				elseif a[2]==205 then --right
					if not (x>=w) then
						x=x+1
					end
				elseif a[2]==56 then
					nextEvent = {"key",56}--alt
					break
				elseif a[2]==28 then --enter
					nextEvent ={"mouse_click",1,x,y}--m1 at x,y
					break
				elseif a[2]==54 then --shift
					nextEvent = {"mouse_click",2,x,y}--m2 at x,y
					break
				end
			end
			--draw it
			term.redirect(native)
			ter.blit()--draw the screen
			p(x,y)
			term.setCursorPos(x,y)
			write"X"
		end
		ter.blit()
		term.setCursorPos(px,py)
	else
		term.redirect(ter)
		coroutine.resume(shellCo,unpack(a))
	end
	term.redirect(native)
	ter.blit()
end
term.redirect(native)
print"Completed."
multishell = mShell
shell = oShell
Edited on 06 March 2015 - 01:12 AM
cdel #12
Posted 02 March 2015 - 05:40 AM
Really neat, but I was just wondering, do normal computers support black text?

Edit: Just realised they do by looking at your screenshots, nevermind :P/>
Edited on 02 March 2015 - 04:41 AM
biggest yikes #13
Posted 02 March 2015 - 08:55 PM
Really neat, but I was just wondering, do normal computers support black text?

Edit: Just realised they do by looking at your screenshots, nevermind :P/>
yes, normal computers support any mix of black and white background/text, and thanks! :)/>

I modified this to enable use of the cursor – basically, you press ALT to spawn the cursor, and use the arrow keys to move it arround. Press ALT again to actually make the program register the press of "alt", ENTER to left-click at that spot, and SHIFT to right-click at that spot. You may use this code, but it requires redirect(an ancient API that I'm probably the last still using) which you can get with:
pastebin get fU9Kj9zr redirect (gopher's API topic found here)
Then
pastebin get nry5Sfg8 startup
Here's the code itself (already out of date)
Non-updated code(use pastebin)
--CONFIG:
--remove 1 - to disable mutlishell
---[[
useMultishell = true
--]]













term.redirect(term.native())
local mShell = multishell
local oShell = shell
multishell = nil
shell = nil
print(multishell)
print(shell)
--load redirect
os.loadAPI"redirect"
--m,ake a new buffer
local w,h = term.getSize()
ter = redirect.createRedirectBuffer(w,h,0,0,true)


local w,h = term.getSize()
local bb = false
local tb = false
local bw = false
local tw = false

local setTextColor = ter.setTextColor
local setBackgroundColor = ter.setBackgroundColor

function term.isColor()
	return true
end

function term.isColour()
	return true
end

function term.setTextColor(c)
	if c ~= colors.white and c ~= colors.black then
		c = colors.white
	end
	
	if bb == true then
		c = colors.white
	end
	
	if bw == true then
		c = colors.black
	end
	
	if c == colors.black then
		tb = true
	else
		tb = false
	end
	
	if c == colors.white then
		tw = true
	else
		tw = false
	end
	
	return setTextColor(c)
end
--local bb = false

function term.setBackgroundColor(c)
	if c ~= colors.white and c ~= colors.black then
		c = colors.black
	end
	
	if c == colors.black then
		bb = true
	else
		bb = false
	end
	
	if c == colors.white then
		bw = true
	else
		bw = false
	end
	
	if tb == true then
		c = colors.white
	end
	
	if tw == true then
		c = colors.black
	end
	
	return setBackgroundColor(c)
end

ter.setTextColour = ter.setTextColor
ter.setBackgroundColour = ter.setBackgroundColor

function term.usingNoColor()
	return true
end

ter.usingNoColour = ter.usingNoColor
UsingNoColor = ter.usingNoColor
UsingNoColour = ter.usingNoColor

function term.noColorVersion()
	return "v1-M"--version 1 modded
end


ter.noColourVersion = ter.noColorVersion
NoColourVersion = ter.noColorVersion
NoColorVersion = ter.noColorVersion
--function ter.native() return ter end
local native = term.current()
--ter = term.current()
term.clear()
term.redirect(ter)
term.clear()
term.setCursorPos(1,1)
--[[code:
1 - started mousepress
table -- returning event
2 - user wants 'alt']]
shellCo = coroutine.create(function()
	if useMultishell then
		os.run({},"rom/programs/advanced/multishell")
	else
		os.run({},"rom/programs/shell")
	end
end)
--[[mouse = coroutine.create(function()
	local inform
	local x
	local y
	local w,h = term.getSize()
	while true do
		local a={coroutine.yield(inform)}

		end
	end
end)]]
os.queueEvent"ignoreThis"
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
local nextEvent
local x,y = 1,1
while coroutine.status(shellCo)=="suspended" do
	--print"1"
	local a
	if nextEvent then
		--p(nextEvent)
		--sleep(1)
		a = nextEvent
	else
		a = {coroutine.yield()}
	end
	--print"2"
	--print"2.5"
	nextEvent = nil
	--nextEvent things:
	if a[1] =="key" and a[2]==56 then --alt
		local px,py = term.getCursorPos()--cursor pos before moving
		term.setCursorBlink(false)
		term.setBackgroundColor(colors.black)
		term.redirect(native)
		term.setTextColor(colors.white)
		term.setCursorPos(x,y)
		write"X"
		while true do
			local a = {coroutine.yield()}
			if a[1]=="key" then
				if a[2]==200 then --up
					if not (y<=1) then
						y=y-1
					end
				elseif a[2]==208  then --down
					if not (y>=h) then
						y=y+1
					end
				elseif a[2]==203 then  --left
					if not (x<=1) then
						x=x-1
					end
				elseif a[2]==205 then --right
					if not (x>=w) then
						x=x+1
					end
				elseif a[2]==56 then
					nextEvent = {"key",56}--alt
					break
				elseif a[2]==28 then --enter
					nextEvent ={"mouse_click",1,x,y}--m1 at x,y
					break
				elseif a[2]==54 then --shift
					nextEvent = {"mouse_click",2,x,y}--m2 at x,y
					break
				end
			end
			--draw it
			term.redirect(native)
			ter.blit()--draw the screen
			p(x,y)
			term.setCursorPos(x,y)
			write"X"
		end
		ter.blit()
		term.setCursorPos(px,py)
	else
		term.redirect(ter)
		coroutine.resume(shellCo,unpack(a))
	end
	term.redirect(native)
	ter.blit()
end
term.redirect(native)
print"Completed."
multishell = mShell
shell = oShell
Cool, I'll check it out, but is there a way to remove the cursor afterwards without rebooting the computer? (And a bug I find with yours is that the editing cursor doesn't appear when using the edit program, but it's still pretty cool.)
Edited on 02 March 2015 - 08:24 PM
Geforce Fan #14
Posted 03 March 2015 - 12:00 AM
Really neat, but I was just wondering, do normal computers support black text?

Edit: Just realised they do by looking at your screenshots, nevermind :P/>
yes, normal computers support any mix of black and white background/text, and thanks! :)/>

I modified this to enable use of the cursor – basically, you press ALT to spawn the cursor, and use the arrow keys to move it arround. Press ALT again to actually make the program register the press of "alt", ENTER to left-click at that spot, and SHIFT to right-click at that spot. You may use this code, but it requires redirect(an ancient API that I'm probably the last still using) which you can get with:
pastebin get fU9Kj9zr redirect (gopher's API topic found here)
Then
pastebin get nry5Sfg8 startup
Here's the code itself (already out of date)
Non-updated code(use pastebin)
--CONFIG:
--remove 1 - to disable mutlishell
---[[
useMultishell = true
--]]













term.redirect(term.native())
local mShell = multishell
local oShell = shell
multishell = nil
shell = nil
print(multishell)
print(shell)
--load redirect
os.loadAPI"redirect"
--m,ake a new buffer
local w,h = term.getSize()
ter = redirect.createRedirectBuffer(w,h,0,0,true)


local w,h = term.getSize()
local bb = false
local tb = false
local bw = false
local tw = false

local setTextColor = ter.setTextColor
local setBackgroundColor = ter.setBackgroundColor

function term.isColor()
	return true
end

function term.isColour()
	return true
end

function term.setTextColor(c)
	if c ~= colors.white and c ~= colors.black then
		c = colors.white
	end
	
	if bb == true then
		c = colors.white
	end
	
	if bw == true then
		c = colors.black
	end
	
	if c == colors.black then
		tb = true
	else
		tb = false
	end
	
	if c == colors.white then
		tw = true
	else
		tw = false
	end
	
	return setTextColor(c)
end
--local bb = false

function term.setBackgroundColor(c)
	if c ~= colors.white and c ~= colors.black then
		c = colors.black
	end
	
	if c == colors.black then
		bb = true
	else
		bb = false
	end
	
	if c == colors.white then
		bw = true
	else
		bw = false
	end
	
	if tb == true then
		c = colors.white
	end
	
	if tw == true then
		c = colors.black
	end
	
	return setBackgroundColor(c)
end

ter.setTextColour = ter.setTextColor
ter.setBackgroundColour = ter.setBackgroundColor

function term.usingNoColor()
	return true
end

ter.usingNoColour = ter.usingNoColor
UsingNoColor = ter.usingNoColor
UsingNoColour = ter.usingNoColor

function term.noColorVersion()
	return "v1-M"--version 1 modded
end


ter.noColourVersion = ter.noColorVersion
NoColourVersion = ter.noColorVersion
NoColorVersion = ter.noColorVersion
--function ter.native() return ter end
local native = term.current()
--ter = term.current()
term.clear()
term.redirect(ter)
term.clear()
term.setCursorPos(1,1)
--[[code:
1 - started mousepress
table -- returning event
2 - user wants 'alt']]
shellCo = coroutine.create(function()
	if useMultishell then
		os.run({},"rom/programs/advanced/multishell")
	else
		os.run({},"rom/programs/shell")
	end
end)
--[[mouse = coroutine.create(function()
	local inform
	local x
	local y
	local w,h = term.getSize()
	while true do
		local a={coroutine.yield(inform)}

		end
	end
end)]]
os.queueEvent"ignoreThis"
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
local nextEvent
local x,y = 1,1
while coroutine.status(shellCo)=="suspended" do
	--print"1"
	local a
	if nextEvent then
		--p(nextEvent)
		--sleep(1)
		a = nextEvent
	else
		a = {coroutine.yield()}
	end
	--print"2"
	--print"2.5"
	nextEvent = nil
	--nextEvent things:
	if a[1] =="key" and a[2]==56 then --alt
		local px,py = term.getCursorPos()--cursor pos before moving
		term.setCursorBlink(false)
		term.setBackgroundColor(colors.black)
		term.redirect(native)
		term.setTextColor(colors.white)
		term.setCursorPos(x,y)
		write"X"
		while true do
			local a = {coroutine.yield()}
			if a[1]=="key" then
				if a[2]==200 then --up
					if not (y<=1) then
						y=y-1
					end
				elseif a[2]==208  then --down
					if not (y>=h) then
						y=y+1
					end
				elseif a[2]==203 then  --left
					if not (x<=1) then
						x=x-1
					end
				elseif a[2]==205 then --right
					if not (x>=w) then
						x=x+1
					end
				elseif a[2]==56 then
					nextEvent = {"key",56}--alt
					break
				elseif a[2]==28 then --enter
					nextEvent ={"mouse_click",1,x,y}--m1 at x,y
					break
				elseif a[2]==54 then --shift
					nextEvent = {"mouse_click",2,x,y}--m2 at x,y
					break
				end
			end
			--draw it
			term.redirect(native)
			ter.blit()--draw the screen
			p(x,y)
			term.setCursorPos(x,y)
			write"X"
		end
		ter.blit()
		term.setCursorPos(px,py)
	else
		term.redirect(ter)
		coroutine.resume(shellCo,unpack(a))
	end
	term.redirect(native)
	ter.blit()
end
term.redirect(native)
print"Completed."
multishell = mShell
shell = oShell
Cool, I'll check it out, but is there a way to remove the cursor afterwards without rebooting the computer? (And a bug I find with yours is that the editing cursor doesn't appear when using the edit program, but it's still pretty cool.)
That's not my bug, that's Redirects'. Though, it's to be expected when an API is three years old.
You press enter or shift and right/left clicks… then the cursor goes away? Are you emulating?

And we shall rise once more, and put shame on the nonbelievers. They once thought they where superior, but they are wrong. We shall bring fourth and distribute until they are a mere monocolor shadow-
From The book of NoColor 4:3
Edited on 02 March 2015 - 11:09 PM
biggest yikes #15
Posted 03 March 2015 - 09:57 PM
Really neat, but I was just wondering, do normal computers support black text?

Edit: Just realised they do by looking at your screenshots, nevermind :P/>
yes, normal computers support any mix of black and white background/text, and thanks! :)/>

I modified this to enable use of the cursor – basically, you press ALT to spawn the cursor, and use the arrow keys to move it arround. Press ALT again to actually make the program register the press of "alt", ENTER to left-click at that spot, and SHIFT to right-click at that spot. You may use this code, but it requires redirect(an ancient API that I'm probably the last still using) which you can get with:
pastebin get fU9Kj9zr redirect (gopher's API topic found here)
Then
pastebin get nry5Sfg8 startup
Here's the code itself (already out of date)
Non-updated code(use pastebin)
--CONFIG:
--remove 1 - to disable mutlishell
---[[
useMultishell = true
--]]













term.redirect(term.native())
local mShell = multishell
local oShell = shell
multishell = nil
shell = nil
print(multishell)
print(shell)
--load redirect
os.loadAPI"redirect"
--m,ake a new buffer
local w,h = term.getSize()
ter = redirect.createRedirectBuffer(w,h,0,0,true)


local w,h = term.getSize()
local bb = false
local tb = false
local bw = false
local tw = false

local setTextColor = ter.setTextColor
local setBackgroundColor = ter.setBackgroundColor

function term.isColor()
	return true
end

function term.isColour()
	return true
end

function term.setTextColor(c)
	if c ~= colors.white and c ~= colors.black then
		c = colors.white
	end
	
	if bb == true then
		c = colors.white
	end
	
	if bw == true then
		c = colors.black
	end
	
	if c == colors.black then
		tb = true
	else
		tb = false
	end
	
	if c == colors.white then
		tw = true
	else
		tw = false
	end
	
	return setTextColor(c)
end
--local bb = false

function term.setBackgroundColor(c)
	if c ~= colors.white and c ~= colors.black then
		c = colors.black
	end
	
	if c == colors.black then
		bb = true
	else
		bb = false
	end
	
	if c == colors.white then
		bw = true
	else
		bw = false
	end
	
	if tb == true then
		c = colors.white
	end
	
	if tw == true then
		c = colors.black
	end
	
	return setBackgroundColor(c)
end

ter.setTextColour = ter.setTextColor
ter.setBackgroundColour = ter.setBackgroundColor

function term.usingNoColor()
	return true
end

ter.usingNoColour = ter.usingNoColor
UsingNoColor = ter.usingNoColor
UsingNoColour = ter.usingNoColor

function term.noColorVersion()
	return "v1-M"--version 1 modded
end


ter.noColourVersion = ter.noColorVersion
NoColourVersion = ter.noColorVersion
NoColorVersion = ter.noColorVersion
--function ter.native() return ter end
local native = term.current()
--ter = term.current()
term.clear()
term.redirect(ter)
term.clear()
term.setCursorPos(1,1)
--[[code:
1 - started mousepress
table -- returning event
2 - user wants 'alt']]
shellCo = coroutine.create(function()
	if useMultishell then
		os.run({},"rom/programs/advanced/multishell")
	else
		os.run({},"rom/programs/shell")
	end
end)
--[[mouse = coroutine.create(function()
	local inform
	local x
	local y
	local w,h = term.getSize()
	while true do
		local a={coroutine.yield(inform)}

		end
	end
end)]]
os.queueEvent"ignoreThis"
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
local nextEvent
local x,y = 1,1
while coroutine.status(shellCo)=="suspended" do
	--print"1"
	local a
	if nextEvent then
		--p(nextEvent)
		--sleep(1)
		a = nextEvent
	else
		a = {coroutine.yield()}
	end
	--print"2"
	--print"2.5"
	nextEvent = nil
	--nextEvent things:
	if a[1] =="key" and a[2]==56 then --alt
		local px,py = term.getCursorPos()--cursor pos before moving
		term.setCursorBlink(false)
		term.setBackgroundColor(colors.black)
		term.redirect(native)
		term.setTextColor(colors.white)
		term.setCursorPos(x,y)
		write"X"
		while true do
			local a = {coroutine.yield()}
			if a[1]=="key" then
				if a[2]==200 then --up
					if not (y<=1) then
						y=y-1
					end
				elseif a[2]==208  then --down
					if not (y>=h) then
						y=y+1
					end
				elseif a[2]==203 then  --left
					if not (x<=1) then
						x=x-1
					end
				elseif a[2]==205 then --right
					if not (x>=w) then
						x=x+1
					end
				elseif a[2]==56 then
					nextEvent = {"key",56}--alt
					break
				elseif a[2]==28 then --enter
					nextEvent ={"mouse_click",1,x,y}--m1 at x,y
					break
				elseif a[2]==54 then --shift
					nextEvent = {"mouse_click",2,x,y}--m2 at x,y
					break
				end
			end
			--draw it
			term.redirect(native)
			ter.blit()--draw the screen
			p(x,y)
			term.setCursorPos(x,y)
			write"X"
		end
		ter.blit()
		term.setCursorPos(px,py)
	else
		term.redirect(ter)
		coroutine.resume(shellCo,unpack(a))
	end
	term.redirect(native)
	ter.blit()
end
term.redirect(native)
print"Completed."
multishell = mShell
shell = oShell
Cool, I'll check it out, but is there a way to remove the cursor afterwards without rebooting the computer? (And a bug I find with yours is that the editing cursor doesn't appear when using the edit program, but it's still pretty cool.)
That's not my bug, that's Redirects'. Though, it's to be expected when an API is three years old.
You press enter or shift and right/left clicks… then the cursor goes away? Are you emulating?

And we shall rise once more, and put shame on the nonbelievers. They once thought they where superior, but they are wrong. We shall bring fourth and distribute until they are a mere monocolor shadow-
From The book of NoColor 4:3
Nope, no emulators, but dat quote tho..
Geforce Fan #16
Posted 04 March 2015 - 11:12 PM
It's a parody of about:mozilla
If you're not emulating, then can you give me steps to recreate the issue you're having?
Also: do you mind if I make a topic for my version?
Edited on 04 March 2015 - 10:14 PM
biggest yikes #17
Posted 05 March 2015 - 03:04 PM
It's a parody of about:mozilla
If you're not emulating, then can you give me steps to recreate the issue you're having?
Also: do you mind if I make a topic for my version?

If you go to the edit program with your version, the typing cursor (like with io.read() which marks which char you are on), it doesn't appear.
As for your topic thing, feel free, just make sure you give credit to me and a link to the original NoColor post.
Edited on 05 March 2015 - 02:05 PM
GopherAtl #18
Posted 05 March 2015 - 07:08 PM
[…] but it requires redirect(an ancient API that I'm probably the last still using) which you can get with:
pastebin get fU9Kj9zr redirect (gopher's API topic found here)

:D/>

Cool, I'll check it out, but is there a way to remove the cursor afterwards without rebooting the computer? (And a bug I find with yours is that the editing cursor doesn't appear when using the edit program, but it's still pretty cool.)
That's not my bug, that's Redirects'. Though, it's to be expected when an API is three years old.
You press enter or shift and right/left clicks… then the cursor goes away? Are you emulating?

:(/>

Actually, I'm vaguely surprised that version of redirect is working at all, as this copy was not updated after they changed term.native to a function and removed term.restore(). I just updated the paste, same pastebin code as before, it should work with old or new versions now, though I only actually tested it on new.

As for the cursor bug… that is not related to the issues I've fixed in redirect. That is, in fact, an issue with your program's use of it. The manual blit mode you're using isn't meant to be used for "live" displays. That's what the redirect objects it makes have a makeActive() function for! If I'm remembering correctly, non-active buffers deliberately put the cursor back how they found it after blits, so they won't interfere with the cursor position on the active buffer.

Grab the fixed redirect api ( fU9Kj9zr ) and try this version Z9F9G5Zy of your program. I added one line, calling ter.makeActive(1,1) when we redirect, which makes the redirect buffer automatically draw straight through to the screen, and commented out the lines that were manually calling ter.blit() Cursor shows up fine with these changes, at a shell and in edit, on a basic computer, which are all I actually tested.
Edited on 05 March 2015 - 06:33 PM
biggest yikes #19
Posted 05 March 2015 - 10:17 PM
-snip-

Actually, I'm vaguely surprised that version of redirect is working at all, as this copy was not updated after they changed term.native to a function and removed term.restore(). I just updated the paste, same pastebin code as before, it should work with old or new versions now, though I only actually tested it on new.

As for the cursor bug… that is not related to the issues I've fixed in redirect. That is, in fact, an issue with your program's use of it. The manual blit mode you're using isn't meant to be used for "live" displays. That's what the redirect objects it makes have a makeActive() function for! If I'm remembering correctly, non-active buffers deliberately put the cursor back how they found it after blits, so they won't interfere with the cursor position on the active buffer.

Grab the fixed redirect api ( fU9Kj9zr ) and try this version Z9F9G5Zy of your program. I added one line, calling ter.makeActive(1,1) when we redirect, which makes the redirect buffer automatically draw straight through to the screen, and commented out the lines that were manually calling ter.blit() Cursor shows up fine with these changes, at a shell and in edit, on a basic computer, which are all I actually tested.
Very nice!
Edited on 05 March 2015 - 09:19 PM
Geforce Fan #20
Posted 06 March 2015 - 02:04 AM
Thanks! I wasn't use the make active because it was broken. I really love the redirect API, and refuse to use anything else xD I wish Dan200 used it instead of the window lagPI

I am a fan of you, Gopher. You make really high quality stuff, and even made me a program to clear water out of a dome with a turtle for me once.

Updated the post with a repost of gopher's fix(so I can update it in the future)
Again, can I make my own topic for my cursor addition?
Edited on 06 March 2015 - 01:11 AM
GopherAtl #21
Posted 06 March 2015 - 02:23 AM
Thanks! I wasn't use the make active because it was broken. I really love the redirect API, and refuse to use anything else xD
Thanks, awesome to know it's still being used, sorry it never got updated publicly - I know I've updated it for myself since the terminal changes, but not released anything that used it in a long time so apparently I never updated it in the thread/on pastebin. That was at the same time as multishell was added, and my own version of multishell was the only released program I had that used it I think? And I didn't bother updating my multishell after one was added to vanilla cc.

I am a fan of you, Gopher. You make really high quality stuff, and even made me a program to clear water out of a dome with a turtle for me once.
Wow, I remember that, on … one of the many servers I've briefly inhabited over the years XD That was a fun little project, working out a way to path a turtle through the interior of the space… lol. It has been so long ago, I'd forgotten about that!
Geforce Fan #22
Posted 06 March 2015 - 03:00 AM
Thanks! I wasn't use the make active because it was broken. I really love the redirect API, and refuse to use anything else xD
Thanks, awesome to know it's still being used, sorry it never got updated publicly - I know I've updated it for myself since the terminal changes, but not released anything that used it in a long time so apparently I never updated it in the thread/on pastebin. That was at the same time as multishell was added, and my own version of multishell was the only released program I had that used it I think? And I didn't bother updating my multishell after one was added to vanilla cc.

I am a fan of you, Gopher. You make really high quality stuff, and even made me a program to clear water out of a dome with a turtle for me once.
Wow, I remember that, on … one of the many servers I've briefly inhabited over the years XD That was a fun little project, working out a way to path a turtle through the interior of the space… lol. It has been so long ago, I'd forgotten about that!
1. Yea, you should check out game-engine on general. It uses redirect for almost everything–it literally writes the entire map to 1 buffer and blits it to a variable x/y to move it.

2. It was incredibly generous of you to do that. Several months later, someone PMed me asking for it. I gave it to them, but had lost the program than initiates it(xD) so he has to go into lua and manually load the APIs and then run it.
Edited on 06 March 2015 - 02:06 AM
biggest yikes #23
Posted 06 March 2015 - 08:56 PM
Again, can I make my own topic for my cursor addition?
I already said yes, just give me credit and a link to the original post. :)/>
SpencerBeige #24
Posted 08 March 2015 - 01:13 PM
but…how…wouldn't you HAVE to use a coloured pc? because your setting black pixels.
MKlegoman357 #25
Posted 08 March 2015 - 02:12 PM
Normal computers can set colors to black and white only, so black text on white background is possible.
GopherAtl #26
Posted 08 March 2015 - 02:51 PM
also, black text is actually just very dark gray. Too dark to be properly readable on a black background, but you can make it out if you squint.
biggest yikes #27
Posted 09 March 2015 - 09:28 PM
but…how…wouldn't you HAVE to use a coloured pc? because your setting black pixels.
normal computers can use term.setTextColor, but the only valid colors are "colors.black" and "colors.white".
GopherAtl #28
Posted 09 March 2015 - 09:36 PM
reposting this from geforce fan's fork thread, as it really applies to this version as much as his

a note about this, it doesn't seem like it actually allows black on white, because it prevents changing the text to black unless the background is white, and vice-versa, and since you have to change one at a time, you effectively just can't change it, period. This would break some programs that actually do support black and white, but use inverted colors to convey information.

I think it would be more practical in a less absolute form, like, as a program like monitor, invoked on a per-program basis as "nocolor <progname> <args>" from the command line, rather than as something that is just applied absolutely and universally on the computer at startup.
biggest yikes #29
Posted 09 March 2015 - 09:39 PM
reposting this from geforce fan's fork thread, as it really applies to this version as much as his

a note about this, it doesn't seem like it actually allows black on white, because it prevents changing the text to black unless the background is white, and vice-versa, and since you have to change one at a time, you effectively just can't change it, period. This would break some programs that actually do support black and white, but use inverted colors to convey information.

I think it would be more practical in a less absolute form, like, as a program like monitor, invoked on a per-program basis as "nocolor <progname> <args>" from the command line, rather than as something that is just applied absolutely and universally on the computer at startup.
1. I'm fairly sure that it should *mostly* be uneffected if the format is already black and white, if that's wrong then that's totally not intentional
2. I guess I could always make a version that does something similar to that (program-based color VM)
GopherAtl #30
Posted 09 March 2015 - 09:58 PM
1. I'm fairly sure that it should *mostly* be uneffected if the format is already black and white, if that's wrong then that's totally not intentional
2. I guess I could always make a version that does something similar to that (program-based color VM)

re: 1, I tested after the original post I quoted, it most definitely prevents edit+ from working as it normally would on a basic computer, everythign is just white on black selected blocks impossible to see (they just look like normal text, not inverted).

re: 2, unless you make it so it doesn't interfere at all with normal b&amp;w programs, it can't be running all the time or you've just traded "can't run some programs designed for color" to "can't run some programs properly designed for black and white"
Edited on 09 March 2015 - 09:04 PM
biggest yikes #31
Posted 09 March 2015 - 10:03 PM
1. I'm fairly sure that it should *mostly* be uneffected if the format is already black and white, if that's wrong then that's totally not intentional
2. I guess I could always make a version that does something similar to that (program-based color VM)

re: 1, I tested after the original post I quoted, it most definitely prevents edit+ from working as it normally would on a basic computer, everythign is just black on white, selected blocks impossible to see (they just look like normal text, not inverted).

re: 2, unless you make it so it doesn't interfere at all with normal b&amp;w programs, it can't be running all the time or you've just traded "can't run some programs designed for color" to "can't run some programs properly designed for black and white"
well alright, I'll look into that
also, about edit+, it doesn't even boot on black and white computers
Edited on 09 March 2015 - 09:16 PM
GopherAtl #32
Posted 09 March 2015 - 10:05 PM
edited my post but you'd already replied, I meant white on black, not black on white. But where the program tries to do white on black, it fails. Which is bad, if the coloring conveys important information.
biggest yikes #33
Posted 09 March 2015 - 11:05 PM
This bug has gotten me absolutely stumped. I know why it's caused, but not how to fix it (unless I want to plop in the file, check if it wants to kick us out if it we're not color, and judge based off that, nobody should ever do that [at least, I don't think of that], so I won't).
I think I'll come back to it tomorrow, that usually helps.
Edited on 09 March 2015 - 10:12 PM