Skip to content
Snippets Groups Projects
Commit d0230054 authored by echicken's avatar echicken
Browse files

Minor bugfixes.

Some updates to comments and example code.
parent 644e9d12
No related branches found
No related tags found
No related merge requests found
...@@ -6,23 +6,28 @@ ...@@ -6,23 +6,28 @@
ansiEdit(x, y, width, height, attributes, frame, scrolling) ansiEdit(x, y, width, height, attributes, frame, scrolling)
- 'x' and 'y' are coordinates for the top left corner of the editor 'x' and 'y' are coordinates for the top left corner of the editor
- 'width' and 'height' are the dimensions of the editor in characters
'width' and 'height' are the dimensions of the editor in characters
(Things will start breaking if you set these values too low) (Things will start breaking if you set these values too low)
- 'attributes' are the default fg/bg colours (see sbbsdefs.js)
- 'frame' is a parent Frame object (see frame.js) to put this ANSI 'attributes' are the default fg/bg colours (see sbbsdefs.js)
editor in, if any. (Optional)
- 'scrolling' is true or false, whether to allow the length of the 'frame' is a parent Frame object (see frame.js) to put this ANSI
ANSI to exceed the fixed height of the ANSI editor editor in, if any. (Optional, false may be passed as a placeholder.)
'scrolling' is true or false, whether to allow the length of the
ANSI to exceed the fixed height of the ANSI editor. (Optional,
defaults to false.)
Methods: Methods:
ansiEdit.getcmd(str) ansiEdit.getcmd(str)
- Acts upon 'str' (eg. a return value from console.inkey()) to draw Acts upon 'str' (eg. a return value from console.inkey()) to draw
a character, move the cursor, or bring up the pop-up menu. a character, move the cursor, or bring up the pop-up menu.
- Returns an object with the following properties: Returns an object with the following properties:
x : x coordinate of the character drawn x : x coordinate of the character drawn
y : y coordinate of the character drawn y : y coordinate of the character drawn
...@@ -31,29 +36,29 @@ ...@@ -31,29 +36,29 @@
ansiEdit.putChar(charObject) ansiEdit.putChar(charObject)
- Draws charObject on the canvas, where charObject is an object Draws charObject on the canvas, where charObject is an object
with properties x, y, ch, and attr, meaning where to draw it, what with properties x, y, ch, and attr, meaning where to draw it, what
to draw, and what colour to draw it in. (See sbbsdefs.js for to draw, and what colour to draw it in. (See sbbsdefs.js for
more on colour attributes.) more on colour attributes.)
ansiEdit.cycle() ansiEdit.cycle()
- Update the ANSI editor's canvas (ansiEdit.getcmd(str) does this Update the ANSI editor's canvas (ansiEdit.getcmd(str) does this
automatically, but you will need to call this after calls to automatically, but you will need to call this after calls to
ansiEdit.putChar().) ansiEdit.putChar().)
ansiEdit.open() ansiEdit.open()
- Only needed if you've used ansiEdit.close() already. New ANSI editor Only needed if you've used ansiEdit.close() already. New ANSI editor
objects open automagically. objects open automagically.
ansiEdit.close() ansiEdit.close()
- Close the ANSI editor and remove it from the screen. Close the ANSI editor and remove it from the screen.
ansiEdit.showUI(boolean) ansiEdit.showUI(boolean)
- Show or hide the cursor and character set (must ansiEdit.cycle() or Show or hide the cursor and character set (must ansiEdit.cycle() or
cycle the parent frame for change to appear on screen.) cycle the parent frame for change to appear on screen.)
Example: Example:
...@@ -74,9 +79,8 @@ ...@@ -74,9 +79,8 @@
b = console.inkey(K_NONE, 5); b = console.inkey(K_NONE, 5);
if(b == "") continue; if(b == "") continue;
c = a.getcmd(b); c = a.getcmd(b);
a.cycle();
if(!c.ch) continue; // No character was drawn if(!c.ch) continue; // No character was drawn
console.gotoxy(1, 23); console.gotoxy(1, 24);
console.putmsg("\1h\1w" + c.toSource()); console.putmsg("\1h\1w" + c.toSource());
} }
*/ */
...@@ -87,7 +91,11 @@ load("tree.js"); ...@@ -87,7 +91,11 @@ load("tree.js");
function ansiEdit(x, y, width, height, attr, frame, scrolling) { function ansiEdit(x, y, width, height, attr, frame, scrolling) {
if(scrolling == undefined) var scrolling = false; if(!frame || frame === undefined)
var frame = new Frame(x, y, width, height, attr);
if(scrolling === undefined)
var scrolling = false;
var str = ""; var str = "";
var esc = ascii(27); var esc = ascii(27);
...@@ -289,7 +297,7 @@ function ansiEdit(x, y, width, height, attr, frame, scrolling) { ...@@ -289,7 +297,7 @@ function ansiEdit(x, y, width, height, attr, frame, scrolling) {
cursor.putmsg(ascii(219)); cursor.putmsg(ascii(219));
charSet.update(characterSet); charSet.update(characterSet);
aFrame.open(); frame.open();
tree.open(); tree.open();
aFrame.cycle(); aFrame.cycle();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment