From 97e0d1a8e548d5bca3cef7e4813e06b9a49d7376 Mon Sep 17 00:00:00 2001 From: deuce <> Date: Wed, 11 Nov 2015 03:40:46 +0000 Subject: [PATCH] Block out the getstr() API, update TODO comments. --- exec/load/dorkit.js | 47 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/exec/load/dorkit.js b/exec/load/dorkit.js index d5840616a4..9779c0cf48 100644 --- a/exec/load/dorkit.js +++ b/exec/load/dorkit.js @@ -236,8 +236,11 @@ var dk = { /* * Writes a string unmodified. + * TODO: This needs to parse ANSI and set attr... */ print:function(string) { + var m; + if (this.local) this.local_io.print(string); if (this.remote) @@ -272,7 +275,6 @@ var dk = { */ waitkey:function(timeout) { var q = new Queue("dorkit_input"); - // TODO: Parse ANSI here! if (q.poll(timeout) === false) return false; return true; @@ -329,6 +331,49 @@ var dk = { } return ret; }, + getstr_defaults:{ + password:false, // Password field (echo password_char instead of string) + password_char:'*', // Character to echo when entering passwords. + upper_case:false, // Convert to upper-case during editing + integer:false, // Input integer values only + decimal:false, // Input decimal values only + ansi:false, // Allows ANSI input + ctrl_a:false, // Allows CTRL-A input + beep:false, // Allows beep input (WTF?) + edit:'', // Edit this value rather than a new input + crlf:true, // Print CRLF after input + exascii:false, // Allow extended ASCII (Higher than 127) + echo:true, // Display input while typing + input_box:false, // Draw an input "box" in a different background attr + select:true, // Select all when editing... first character typed if not movement will erase + attr:undefined, // Foreground attribute... used to draw the input box and for output... undefined means "use current" + sel_attr:undefined, // Selected text attribute... used for edit value when select is true. Undefined uses inverse (swaps fg and bg, leaving bright and blink unswapped) + len:80 // Max length and length of input box + }, + getstr:function(in_opts) { + var i; + var opt={}; + var str; + var orig_attr = new Attribute(this.attr); + + // Set up option defaults + for (i in this.getstr_defaults) { + if (in_opts[i] !== undefined) + opt[i] = in_opts[i]; + else + opt[i] = this.getstr_defaults[i]; + } + if (opt.attr === undefined) + opt.attr=new Attribute(this.attr); + if (opt.sel_attr === undefined) { + opt.sel_attr=new Attribute(this.attr); + i = opt.sel_attr.fg; + opt.sel_attr.fg = opt.sel_attr.bg; + opt.sel_attr.bg = i; + } + str = opt.edit; + // Draw the input box... + }, }, connection:{ type:undefined, -- GitLab