Skip to content
Snippets Groups Projects
Commit 4640135e authored by mcmlxxix's avatar mcmlxxix
Browse files

Reworked GetColor() and DrawLine() functions

parent 87189568
No related branches found
No related tags found
No related merge requests found
......@@ -7,16 +7,30 @@ function getColor(color, intensity)
{ //TAKE A STRING AND RETURN THE CORRESPONDING ANSI COLOR CODE
if(intensity=="high") inten="\1h";
else inten="\1n";
if(color=="black") return ("\1k" + inten);
if(color=="grey") return ("\1h"+ inten);
if(color=="cyan") return ("\1c"+ inten);
if(color=="yellow") return ("\1y"+ inten);
if(color=="green") return ("\1g"+ inten);
if(color=="white") return ("\1w"+ inten);
if(color=="red") return ("\1r"+ inten);
if(color=="blue") return ("\1b"+ inten);
if(color=="magenta") return ("\1m"+ inten);
switch(color)
{
case "black":
return(inten + "\1k");
case "grey":
return(inten?("\1n" + inten):"\1n");
case "cyan":
return(inten + "\1c");
case "yellow":
return(inten + "\1y");
case "green":
return(inten + "\1g");
case "white":
return(inten + "\1w");
case "red":
return(inten + "\1r");
case "blue":
return(inten + "\1b");
case "magenta":
return(inten + "\1m");
default:
return("\1n");
}
}
function GetLastWord(text)
{
......@@ -44,14 +58,23 @@ function PrintPadded(string,length,padding,justification)
if(!justification) justification="left";
var padlength=length-console.strlen(string);
var newstring=string;
var padded="\1k";
var padded="";
for(p=0;p<padlength;p++) padded+=padding;
if(justification=="left") newstring+=(padded);
if(justification=="right") newstring=(padded + newstring);
return(newstring);
}
function DrawLine(x,y,length,color)
{
console.gotoxy(x,y);
for(i=0;i<length;i++)
{
console.putmsg((color?color:"\1k\1h") + "\xc4");
}
}
function ClearLine(length,x,y)
{
write(console.ansi(ANSI_NORMAL));
if(x && y) console.gotoxy(x,y);
if(length) printf("%*s",length,"");
else console.cleartoeol();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment