diff options
author | 2014-03-26 10:15:53 -0400 | |
---|---|---|
committer | 2014-03-26 10:15:53 -0400 | |
commit | f65b2b2a66f05b20010256ca1d81cc3252ea1471 (patch) | |
tree | c7ee3cd4753a9e8a73f9e9d3e8a45f96eb5b36c7 /modules/lua | |
parent | 6304010d93b3cfe43e246dbb49c60d147a366b1b (diff) | |
download | textadept-f65b2b2a66f05b20010256ca1d81cc3252ea1471.tar.gz textadept-f65b2b2a66f05b20010256ca1d81cc3252ea1471.zip |
Include my new "lspawn" module by default for spawning processes.
The `textadept.run` module now uses `spawn()` instead of `io.popen()`.
This module replaces the dependency on winapi. Removed experimental
`io.popen()` and `os.execute()` hooks. They may be re-implemented later using
`spawn()`.
Diffstat (limited to 'modules/lua')
-rw-r--r-- | modules/lua/api | 10 | ||||
-rw-r--r-- | modules/lua/init.lua | 3 | ||||
-rw-r--r-- | modules/lua/tags | 9 |
3 files changed, 20 insertions, 2 deletions
diff --git a/modules/lua/api b/modules/lua/api index 125d6a9f..08452f8d 100644 --- a/modules/lua/api +++ b/modules/lua/api @@ -555,7 +555,7 @@ current_pos buffer.current_pos (number)\nThe caret's position.\nWhen set, does n currentdir lfs.currentdir()\nReturns a string with the current working directory or nil plus an error\nstring. cursor buffer.cursor (number)\nThe display cursor type.\n\n* `buffer.CURSORNORMAL`\n The text insert cursor.\n* `buffer.CURSORARROW`\n The arrow cursor.\n* `buffer.CURSORWAIT`\n The wait cursor.\n* `buffer.CURSORREVERSEARROW`\n The reversed arrow cursor.\n\nThe default value is `buffer.CURSORNORMAL`. cut buffer.cut(buffer)\nCuts the selected text to the clipboard.\nMultiple selections are copied in order with no delimiters. Rectangular\nselections are copied from top to bottom with end of line characters. Virtual\nspace is not copied.\n@param buffer A buffer. -cwd textadept.run.cwd (string, Read-only)\nThe most recently executed compile or run shell command's working directory.\nIt is used for going to error messages with relative file paths. +cwd textadept.run.cwd (string, Read-only)\nThe most recently executed compile or run shell command's working\ndirectory.\nIt is used for going to error messages with relative file paths. date os.date([format [, time]])\nReturns a string or a table containing date and time, formatted according\nto the given string `format`.\n\nIf the `time` argument is present, this is the time to be formatted\n(see the `os.time` function for a description of this value). Otherwise,\n`date` formats the current time.\n\nIf `format` starts with '`!`', then the date is formatted in Coordinated\nUniversal Time. After this optional character, if `format` is the string\n"`*t`", then `date` returns a table with the following fields: `year` (four\ndigits), `month` (1-12), `day` (1-31), `hour` (0-23), `min` (0-59), `sec`\n(0-61), `wday` (weekday, Sunday is 1), `yday` (day of the year), and `isdst`\n(daylight saving flag, a boolean). This last field may be absent if the\ninformation is not available.\n\nIf `format` is not "`*t`", then `date` returns the date as a string,\nformatted according to the same rules as the ANSI C function `strftime`.\n\nWhen called without arguments, `date` returns a reasonable date and time\nrepresentation that depends on the host system and on the current locale\n(that is, `os.date()` is equivalent to `os.date("%c")`).\n\nOn non-Posix systems, this function may be not thread safe because of its\nreliance on C function `gmtime` and C function `localtime`. debug _G.debug (module)\nLua debug module. debug debug.debug()\nEnters an interactive mode with the user, running each string that\nthe user enters. Using simple commands and other debug facilities,\nthe user can inspect global and local variables, change their values,\nevaluate expressions, and so on. A line containing only the word `cont`\nfinishes this function, so that the caller continues its execution.\n\nNote that commands for `debug.debug` are not lexically nested within any\nfunction and so have no direct access to local variables. @@ -750,6 +750,7 @@ keychain keys.keychain (table)\nThe current chain of key sequences. (Read-only.) keys _G.keys (module)\nManages key bindings in Textadept. keys _G.keys (table)\nMap of key bindings to commands, with language-specific key tables assigned\nto a lexer name key. keys textadept.keys (module)\nDefines key commands for Textadept.\nThis set of key commands is pretty standard among other text editors. If\napplicable, load this module second to last in your *~/.textadept/init.lua*,\nbefore `textadept.menu`. +kill proc.kill(proc)\nKills running `proc`.\n@param proc A running process created by `spawn()`. last_char_includes lexer.last_char_includes(s)\nCreates and returns a pattern that verifies that string set *s* contains the\nfirst non-whitespace character behind the current match position.\n@param s String character set like one passed to `lpeg.S()`.\n@usage local regex = l.last_char_includes('+-*!%^&|=,([{') *\n l.delimited_range('/')\n@return pattern ldexp math.ldexp(m, e)\nReturns 'm2^e' (`e` should be an integer). len string.len(s)\nReceives a string and returns its length. The empty string `""` has\nlength 0. Embedded zeros are counted, so `"a\000bc\000"` has length 5. @@ -923,6 +924,8 @@ preload package.preload (table)\nA table to store loaders for specific modules ( print _G.print(···)\nReceives any number of arguments and prints their values to `stdout`, using\nthe `tostring` function to convert each argument to a string. `print` is not\nintended for formatted output, but only as a quick way to show a value,\nfor instance for debugging. For complete control over the output, use\n`string.format` and `io.write`. print lexer.print (pattern)\nA pattern that matches any printable character (' ' to '~'). print ui.print(...)\nPrints the given string messages to the message buffer.\nOpens a new buffer if one has not already been opened for printing messages.\n@param ... Message strings. +proc _G.proc (module)\nUserdata representing a process created by `spawn()`. +proc textadept.run.proc (process)\nThe currently running process or the most recent process run. process args.process(arg)\nProcesses command line argument table *arg*, handling switches previously\ndefined using `args.register()` and treating unrecognized arguments as\nfilenames to open.\nEmits an `ARG_NONE` event when no arguments are present.\n@param arg Argument table.\n@see register\n@see events properties _SCINTILLA.properties (table)\nMap of Scintilla property names to table values containing their "get"\nfunction IDs, "set" function IDs, return types, and wParam types.\nThe wParam type will be non-zero if the property is indexable.\nTypes are the same as in the `functions` table.\n@see functions property buffer.property (table)\nMap of key-value string pairs used by lexers. @@ -1102,6 +1105,7 @@ snippets _G.snippets (table)\nMap of snippet triggers with their snippet text, w snippets textadept.snippets (module)\nSnippets for Textadept. sort table.sort(list [, comp])\nSorts list elements in a given order, *in-place*, from `list[1]` to\n`list[#list]`. If `comp` is given, then it must be a function that receives\ntwo list elements and returns true when the first element must come before\nthe second in the final order (so that `not comp(list[i+1],list[i])` will be\ntrue after the sort). If `comp` is not given, then the standard Lua operator\n`<` is used instead.\n\nThe sort algorithm is not stable; that is, elements considered equal by the\ngiven order may have their relative positions changed by the sort. space lexer.space (pattern)\nA pattern that matches any whitespace character ('\t', '\v', '\f', '\n',\n'\r', space). +spawn _G.spawn(argv, working_dir, stdout_cb, stderr_cb, exit_cb)\nSpawns an interactive child process *argv* in a separate thread with the help\nof GLib.\n@param argv A UTF-8-encoded command line string containing the program's name\n followed by arguments to pass to it. `PATH` is searched for program names.\n@param working_dir The child's UTF-8 current working directory (cwd) or `nil`\n to inherit the parent's.\n@param stdout_cb A Lua function that accepts a string parameter for a block\n of standard output read from the child. Stdout is read asynchronously in\n 1KB or 0.5KB blocks (depending on the platform), or however much data is\n available at the time. All text is encoded in `_CHARSET`.\n@param stderr_cb A Lua function that accepts a string parameter for a block\n of standard error read from the child. Stderr is read asynchronously in 1KB\n or 0.5kB blocks (depending on the platform), or however much data is\n available at the time. All text is encoded in `_CHARSET`.\n@param exit_cb A Lua function that is called when the child process finishes.\n The child's exit status is passed.\n@usage spawn('lua buffer.filename', nil, print)\n@usage proc = spawn('lua -e "print(io.read())", nil, print)\n proc:write('foo\\n')\n@return proc\n@see _G._CHARSET\n@see _G.proc split view.split(view, vertical)\nSplits the view into top and bottom views (unless *vertical* is `true`),\nfocuses the new view, and returns both the old and new views.\nIf *vertical* is `false`, splits the view vertically into left and\nright views.\nEmits a `VIEW_NEW` event.\n@param view The view to split.\n@param vertical Optional flag indicating whether or not to split the view\n vertically. The default value is `false`, for horizontal.\n@return old view and new view.\n@see events.VIEW_NEW sqrt math.sqrt(x)\nReturns the square root of `x`. (You can also use the expression `x^0.5`\nto compute this value.) standard_dropdown ui.dialogs.standard_dropdown(options)\nPrompts the user with a drop down item selection dialog defined by dialog\noptions table *options* and with localized "Ok" and "Cancel" buttons,\nreturning the selected button's index along with the selected item's index\nor, if *options*.`string_output` is `true`, the selected button's label along\nwith the selected item's text.\nIf the dialog closed due to *options*.`exit_onchange`, returns `4` along with\neither the selected item's index or text. If the dialog timed out, returns\n`0` or `"timeout"`. If the user canceled the dialog, returns `-1` or\n`"delete"`.\n@param options Table of key-value option pairs for the drop down dialog.\n\n * `title`: The dialog's title text.\n * `text`: The dialog's main message text.\n * `items`: The list of string items to show in the drop down.\n * `no_cancel`: Do not display the "Cancel" button. The default value is\n `false`.\n * `exit_onchange`: Close the dialog after selecting a new item. The default\n value is `false`.\n * `select`: The index of the initially selected list item. The default\n value is `1`.\n * `string_output`: Return the selected button's label or the dialog's exit\n status along with the selected item's text instead of the button's index\n or the dialog's exit code along with the item's index. The default value\n is `false`.\n * `width`: The dialog's pixel width.\n * `height`: The dialog's pixel height.\n * `float`: Show the dialog on top of all desktop windows. The default value\n is `false`.\n * `timeout`: the integer number of seconds the dialog waits for the user to\n select a button before timing out. Dialogs do not time out by default.\n@return selected button or exit code, selected item @@ -1109,10 +1113,12 @@ standard_inputbox ui.dialogs.standard_inputbox(options)\nPrompts the user with a start_styling buffer.start_styling(buffer, position, style_mask, styling_mask)\nBegins styling at position *position* with styling bit-mask *styling_mask*.\n*styling_mask* specifies which style bits can be set with\n`buffer:set_styling()`.\n@param buffer A buffer.\n@param position The position in *buffer* to start styling at.\n@param styling_mask The bit mask of style bits that can be set when styling.\n@usage buffer:start_styling(0, 0xFF) starts_line lexer.starts_line(patt)\nCreates and returns a pattern that matches pattern *patt* only at the\nbeginning of a line.\n@param patt The LPeg pattern to match on the beginning of a line.\n@usage local preproc = token(l.PREPROCESSOR, #P('#') * l.starts_line('#' *\n l.nonnewline^0))\n@return pattern status coroutine.status(co)\nReturns the status of coroutine `co`, as a string: `"running"`, if\nthe coroutine is running (that is, it called `status`); `"suspended"`, if\nthe coroutine is suspended in a call to `yield`, or if it has not started\nrunning yet; `"normal"` if the coroutine is active but not running (that\nis, it has resumed another coroutine); and `"dead"` if the coroutine has\nfinished its body function, or if it has stopped with an error. +status proc.status(proc)\nReturns the status of `proc`, which is either "running" or "terminated".\n@param proc A process created by `spawn()`.\n@return "running" or "terminated" statusbar_text ui.statusbar_text (string, Write-only)\nThe text displayed in the statusbar. stderr io.stderr (file)\nStandard error. stdin io.stdin (file)\nStandard in. stdout io.stdout (file)\nStandard out. +stop textadept.run.stop()\nStops the currently running process, if any. string _G.string (module)\nLua string module. stuttered_page_down buffer.stuttered_page_down(buffer)\nMoves the caret to the bottom of the page or, if already there, down one\npage.\n@param buffer A buffer. stuttered_page_down_extend buffer.stuttered_page_down_extend(buffer)\nLike `buffer:stuttered_page_down()`, but extends the selected text to the new\nposition.\n@param buffer A buffer. @@ -1214,6 +1220,7 @@ view_eol buffer.view_eol (bool)\nDisplay end of line characters.\nThe default va view_ws buffer.view_ws (number)\nThe whitespace visibility mode.\n\n* `buffer.WS_INVISIBLE`\n Whitespace is invisible.\n* `buffer.WS_VISIBLEALWAYS`\n Display all space characters as dots and tab characters as arrows.\n* `buffer.WS_VISIBLEAFTERINDENT`\n Display only non-indentation spaces and tabs as dots and arrows.\n\nThe default value is `buffer.WS_INVISIBLE`. virtual_space_options buffer.virtual_space_options (number)\nThe virtual space mode.\n\n* `buffer.VS_NONE`\n Disable virtual space.\n* `buffer.VS_RECTANGULARSELECTION`\n Enable virtual space only for rectangular selections.\n* `buffer.VS_USERACCESSIBLE`\n Enable virtual space.\n\nWhen virtual space is enabled, the caret may move into the space past end\nof line characters.\nThe default value is `buffer.VS_NONE`. visible_from_doc_line buffer.visible_from_doc_line(buffer, line)\nReturns the displayed line number of actual line number *line*, taking hidden\nlines into account, or `-1` if *line* is outside the range of lines in the\nbuffer.\nLines can occupy more than one display line if they wrap.\n@param buffer A buffer.\n@param line The line number in *buffer* to use.\n@return number +wait proc.wait(proc)\nBlocks until `proc` finishes.\n@param proc A process created by `spawn()`. whitespace_chars buffer.whitespace_chars (string)\nThe string set of characters recognized as whitespace characters.\nSet this only after setting `buffer.word_chars`.\nThe default value is a string that contains all non-newline characters less\nthan ASCII value 33. whitespace_size buffer.whitespace_size (number)\nThe pixel size of the dots that represent space characters when whitespace\nis visible.\nThe default value is `1`. whole_word ui.find.whole_word (bool)\nMatch search text only when it is surrounded by non-word characters in\nsearches.\nThe default value is `false`. @@ -1245,6 +1252,7 @@ wrap_visual_flags buffer.wrap_visual_flags (number)\nThe wrapped line visual fla wrap_visual_flags_location buffer.wrap_visual_flags_location (number)\nThe wrapped line visual flag drawing mode.\n\n* `buffer.WRAPVISUALFLAGLOC_DEFAULT`\n Draw a visual flag near the view's right margin.\n* `buffer.WRAPVISUALFLAGLOC_END_BY_TEXT`\n Draw a visual flag near text at the end of a wrapped line.\n* `buffer.WRAPVISUALFLAGLOC_START_BY_TEXT`\n Draw a visual flag near text at the beginning of a subline.\n\nThe default value is `buffer.WRAPVISUALFLAGLOC_DEFAULT`. write file:write(···)\nWrites the value of each of its arguments to `file`. The arguments must be\nstrings or numbers.\n\nIn case of success, this function returns `file`. Otherwise it returns nil\nplus a string describing the error. write io.write(···)\nEquivalent to `io.output():write(···)`. +write proc.write(proc, input)\nWrites string `input` to the stdin of `proc`.\n@param proc A process created by `spawn()`.\n@param input Standard input for `proc`. x_offset buffer.x_offset (number)\nThe horizontal scroll pixel position.\nA value of `0` is the normal position with the first text column visible at\nthe left of the view. xdigit lexer.xdigit (pattern)\nA pattern that matches any hexadecimal digit ('0'-'9', 'A'-'F', 'a'-'f'). xor bit32.xor(...)\nReturns the bitwise "exclusive or" of its operands. diff --git a/modules/lua/init.lua b/modules/lua/init.lua index 0f68a1e1..1ba3ee02 100644 --- a/modules/lua/init.lua +++ b/modules/lua/init.lua @@ -35,7 +35,8 @@ M.sense.syntax.type_assignments = { ['^([%w_%.]+)%s*$'] = '%1', -- foo = textadept.adeptsense ['^(_M%.textadept%.adeptsense)%.new'] = '%1', ['require%s*%(?%s*(["\'])([%w_%.]+)%1%)?'] = '%2', - ['^io%.p?open%s*%b()%s*$'] = 'file' + ['^io%.p?open%s*%b()%s*$'] = 'file', + ['^spawn%s*%b()%s*$'] = 'proc' } M.sense.api_files = {_HOME..'/modules/lua/api'} M.sense:add_trigger('.') diff --git a/modules/lua/tags b/modules/lua/tags index 3474cd81..a6d11c12 100644 --- a/modules/lua/tags +++ b/modules/lua/tags @@ -771,6 +771,7 @@ keys _ 0;" m keys _ 0;" t keys _ 0;" t keys _ 0;" t class:textadept +kill _ 0;" f class:proc last_char_includes _ 0;" f class:lexer ldexp _ 0;" f class:math len _ 0;" f class:string @@ -950,6 +951,9 @@ preload _ 0;" F class:package print _ 0;" F class:lexer print _ 0;" f print _ 0;" f class:ui +proc _ 0;" F class:textadept.run +proc _ 0;" m +proc _ 0;" t process _ 0;" f class:args properties _ 0;" t class:_SCINTILLA property _ 0;" F class:buffer @@ -1129,6 +1133,7 @@ snippets _ 0;" t snippets _ 0;" t class:textadept sort _ 0;" f class:table space _ 0;" F class:lexer +spawn _ 0;" f split _ 0;" f class:view sqrt _ 0;" f class:math standard_dropdown _ 0;" f class:ui.dialogs @@ -1136,10 +1141,12 @@ standard_inputbox _ 0;" f class:ui.dialogs start_styling _ 0;" f class:buffer starts_line _ 0;" f class:lexer status _ 0;" f class:coroutine +status _ 0;" f class:proc statusbar_text _ 0;" F class:ui stderr _ 0;" F class:io stdin _ 0;" F class:io stdout _ 0;" F class:io +stop _ 0;" f class:textadept.run string _ 0;" m string _ 0;" t stuttered_page_down _ 0;" f class:buffer @@ -1258,6 +1265,7 @@ view_eol _ 0;" F class:buffer view_ws _ 0;" F class:buffer virtual_space_options _ 0;" F class:buffer visible_from_doc_line _ 0;" f class:buffer +wait _ 0;" f class:proc whitespace_chars _ 0;" F class:buffer whitespace_size _ 0;" F class:buffer whole_word _ 0;" F class:ui.find @@ -1289,6 +1297,7 @@ wrap_visual_flags _ 0;" F class:buffer wrap_visual_flags_location _ 0;" F class:buffer write _ 0;" f class:file write _ 0;" f class:io +write _ 0;" f class:proc x_offset _ 0;" F class:buffer xdigit _ 0;" F class:lexer xor _ 0;" f class:bit32 |