From 602c3f947cab1694ea79864e002c0f82f9db455a Mon Sep 17 00:00:00 2001 From: asciibene Date: Thu, 14 Apr 2022 23:43:11 -0400 Subject: [PATCH] Improvements...III --- README.md | 7 ++++ main.lua | 91 +++++++++++++++++++++++++++++++++++++++++-------- simplefuncs.lua | 6 ++++ 3 files changed, 89 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index d4a05d5..d0e831d 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,10 @@ graphed is a simple tool to create _ascii art_ It is very rudimentary for now... +## Changelog +- Version 0.2 + - *WIP* +- Version 0.1 + - added file write/load + - + diff --git a/main.lua b/main.lua index 7f68742..5f6096d 100644 --- a/main.lua +++ b/main.lua @@ -2,13 +2,11 @@ nc = require("nocurses") dofile("simplefuncs.lua") -- Misc nc funcs ============================ - COLORS={"BLACK","RED","GREEN","YELLOW","BLUE","MAGENTA","CYAN","WHITE"} MSIZE_X=32 -- Map MSIZE_Y=24 ---- size PL_GLYPH="@" -VER=0.08 --- MAKE Map matrix ------------- +VER=0.10 -- -------------- START FUNC ----------- function start() nc.setcurshape("BAR") @@ -17,7 +15,7 @@ function start() map=mkmat() mapcolors=mkmat() p=mkpointer() - + nc.clrscr() -- Now main loop main() end @@ -33,7 +31,12 @@ function drawmap() end -- XXX draw last info line XXX nc.gotoxy(0,MSIZE_Y+1) - print("X:"..p.x.." | ".." Y:"..p.y.." ") + print("X:"..p.x.." | ".." Y:"..p.y.." ") + if mesg_string~=nil then + nc.gotoxy(1,1) + print(mesg_string) + mesg_string=nil + end end function drawmap_fg() -- Draw map foreground @@ -42,18 +45,20 @@ function drawmap_fg() -- Draw map foreground print(p.glyph) nc.setfontcolor("WHITE") end ------------ main func ----- +-- end drawmap--> main func ---------VVVVVVVVV function main() - printul("Graphed") - print("version "..VER) + printul("Graphed -- 'Graphical Editor' --") + printcol("http://asciibene.tx0.org/","YELLOW") + printcol("version "..VER,"CYAN") while exitbool~=true do if await_cmd()~=0 then drawmap() drawmap_fg() - end + end end nc.clrscr() printul("Goodbye...") + end @@ -64,17 +69,25 @@ function await_cmd() k=string.char(nc.getch()) if k=="h" and p.x>1 then movep(-1,0) - elseif k=="j" and p.y<=MSIZE_Y then + elseif k=="j" and p.y1 then movep(0,-1) elseif k=="l" and p.x3 then + movep(-3,0) + elseif k=="J" and p.y3 then + movep(0,-3) + elseif k=="L" and p.x change current glyph") + print("c -> change current glyph") print(". -> place current glyph on screen") print("x -> delete glyph under cursor") -- TODO @@ -105,6 +149,20 @@ function help() nc.setfontcolor("WHITE") end +function changesize() + nc.clrscr() + print("Enter y size(lines)") + yin=io.read("l") + print("Enter y size(lines)") + xin=io.read("l") + + MSIZE_X=tonumber(xin) + MSIZE_Y=tonumber(yin) + +end + + + function write() nc.clrscr() print("Enter Filename") @@ -117,9 +175,10 @@ function write() end fp:write("\n") end + fp:close() nc.clrscr() - showmesg("wrote to file:'"..fn.."'. Press enter") + mesg_string="Wrote to file : "..fn end function movep(dx,dy) @@ -136,5 +195,7 @@ function changep() p.glyph=c end +-- ------------------------------------------- +-- To write a ephemeral message that gets erased after any input (unlike 'press enter') messages then set 'mesg_string' to any value -- ------------------------------------------ start() diff --git a/simplefuncs.lua b/simplefuncs.lua index 6447b06..a1912be 100644 --- a/simplefuncs.lua +++ b/simplefuncs.lua @@ -6,6 +6,12 @@ function printul(s) nc.setunderline(false) end +function printcol(str,col) + nc.setfontcolor(col) + print(str) + nc.setfontcolor("WHITE") +end + function mkmat() local mt mt = {} -- create the matrix