Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
api:term [2016/02/29 23:40]
payonel [Term API]
api:term [2017/05/11 18:12]
payonel
Line 39: Line 39:
   The `hint` parameter is used for tab completion. It can either be a table with strings or a function that returns a table of strings and takes two parameters, the current text and the position in that text, i.e. the signature of the callback is `function(line:​string,​ pos:​number):​table`.  ​   The `hint` parameter is used for tab completion. It can either be a table with strings or a function that returns a table of strings and takes two parameters, the current text and the position in that text, i.e. the signature of the callback is `function(line:​string,​ pos:​number):​table`.  ​
   The `pwchar` parameter, when given, causes input to be masked using the first char of the given string. For example, providing `"​*"​` will make all entered characters appear as stars. The returned value will still be the actual text inserted, of course.  ​   The `pwchar` parameter, when given, causes input to be masked using the first char of the given string. For example, providing `"​*"​` will make all entered characters appear as stars. The returned value will still be the actual text inserted, of course.  ​
-  The function will return a string if input was successful, ​or `nil` if there was no more input (user pressed Ctrl+D or Ctrl+C ​or the terminal became unavailable).  ​+  The function will return a string if input was successful, `nil` if the pipe was closed ​(^d), or `false` if the pipe was interrupted (^c) 
   //Note//: `io.stdin:​read()` uses this function.  ​   //Note//: `io.stdin:​read()` uses this function.  ​
   //Note 2//: This will return the entered string with the \n (new line character). If you want only the entered string to be returned, use `io.read()`.   //Note 2//: This will return the entered string with the \n (new line character). If you want only the entered string to be returned, use `io.read()`.
Line 45: Line 46:
   Allows writing optionally wrapped text to the terminal starting at the current cursor position, updating the cursor accordingly. It automatically converts tab characters to spaces using `text.detab`. If `wrap` is true, it will automatically word-wrap the text. It will scroll the displayed buffer if the cursor exceeds the bottom of the display area, but *not* if it exceeds the right of the display area (when `wrap` is false).  ​   Allows writing optionally wrapped text to the terminal starting at the current cursor position, updating the cursor accordingly. It automatically converts tab characters to spaces using `text.detab`. If `wrap` is true, it will automatically word-wrap the text. It will scroll the displayed buffer if the cursor exceeds the bottom of the display area, but *not* if it exceeds the right of the display area (when `wrap` is false).  ​
   //Note//: This method respects io redirection. That is to say, `term.write` writes to the same stream as io.stdout   //Note//: This method respects io redirection. That is to say, `term.write` writes to the same stream as io.stdout
-- `term.readKeyboard(ops:​table)` 
- 
-  (new in OpenOS 1.6) 
-  ​ 
-  Reads input directly from keyboard events and does not consider io.stdin. This method should only be used when the user specifically wants to bypass stdin and read directly from the keyboard hardware. `ops` is used identically to `ops` as defined in `term.read`. 
-- `term.drawText(value:​string[,​ wrap:​boolean[,​ window:​table]])` 
- 
-  (new in OpenOS 1.6)  ​ 
  
-  Renders `value` directly to the gpu bound to the current window or `window` if provided, wrapping vertically if `wrap` at the current cursor position of the window. Use this method to bypass the io stream. Generally, this method should not be used, but rather `term.write`. 
 - `term.bind(gpu,​ screen, [keyboard, [window:​table]])` - `term.bind(gpu,​ screen, [keyboard, [window:​table]])`