mirror of
				https://github.com/ctruLua/ctruLua.git
				synced 2025-10-27 16:39:29 +00:00 
			
		
		
		
	Moved ctr.gfx.set|getTextSize to ctr.gfx.font.set|getSize, added missing documentation to font:width
Started working again on the editor
This commit is contained in:
		
							parent
							
								
									b798818e99
								
							
						
					
					
						commit
						347e480d5a
					
				
					 7 changed files with 38 additions and 34 deletions
				
			
		|  | @ -15,4 +15,4 @@ return { | |||
| 	["keyword.control"] = hex(0xF92672FF), | ||||
| 	["keyword.operator"] = hex(0xF92672FF), | ||||
| 	["support.function"] = hex(0x66D9EFFF) | ||||
| } | ||||
| } | ||||
|  |  | |||
|  | @ -35,12 +35,13 @@ local coloredLines = syntax(lines, color) | |||
| 
 | ||||
| -- Variables | ||||
| local lineHeight = 10 | ||||
| local fontSize = 9 | ||||
| local cursorX, cursorY = 1, 1 | ||||
| local scrollX, scrollY = 0, 0 | ||||
| 
 | ||||
| -- Helper functions | ||||
| local function displayedText(text) | ||||
| 	return text:gsub("\t", "    ") | ||||
| 	return text:gsub("\t", "    "), nil | ||||
| end | ||||
| 
 | ||||
| -- Set defaults | ||||
|  | @ -48,6 +49,7 @@ gfx.set3D(false) | |||
| gfx.color.setDefault(color.default) | ||||
| gfx.color.setBackground(color.background) | ||||
| gfx.font.setDefault(font) | ||||
| gfx.font.setSize(fontSize) | ||||
| 
 | ||||
| while ctr.run() do | ||||
| 	hid.read() | ||||
|  | @ -157,11 +159,7 @@ while ctr.run() do | |||
| 
 | ||||
| 			for _,colored in ipairs(coloredLines[i]) do | ||||
| 				local str = displayedText(colored[1]) | ||||
| 
 | ||||
| 				gfx.color.setDefault(colored[2]) | ||||
| 				gfx.text(x, y, str) | ||||
| 				gfx.color.setDefault(color.default) | ||||
| 
 | ||||
| 				gfx.text(x, y, str, fontSize, colored[2]) | ||||
| 				x = x + font:width(str) | ||||
| 			end | ||||
| 		end | ||||
|  | @ -184,4 +182,4 @@ while ctr.run() do | |||
| 	gfx.render() | ||||
| end | ||||
| 
 | ||||
| font:unload() | ||||
| font:unload() | ||||
|  |  | |||
|  | @ -50,7 +50,7 @@ local syntax = { | |||
| return function(lines, color) | ||||
| 	local ret = {} | ||||
| 
 | ||||
| 	for _,line in ipairs(lines) do | ||||
| 	for _, line in ipairs(lines) do | ||||
| 		local colored = { { line, color.default } } | ||||
| 
 | ||||
| 		for _, patterns in ipairs(syntax) do | ||||
|  | @ -87,4 +87,4 @@ return function(lines, color) | |||
| 	end | ||||
| 
 | ||||
| 	return ret | ||||
| end | ||||
| end | ||||
|  |  | |||
|  | @ -12,7 +12,7 @@ local function displayError(err, trace) | |||
| 	gfx.set3D(false) | ||||
| 	gfx.color.setBackground(0xFF0000B3) | ||||
| 	gfx.color.setDefault(0xFFFDFDFD) | ||||
| 	gfx.setTextSize(12) | ||||
| 	gfx.font.setSize(12) | ||||
| 	gfx.font.setDefault(gfx.font.load(ctr.root .. "resources/VeraMono.ttf")) | ||||
| 
 | ||||
| 	while ctr.run() do | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Reuh
						Reuh