Commit Graph

237 Commits

Author SHA1 Message Date
takase1121 e0099485ab kill process when pipe is closed 2021-07-08 11:29:01 +08:00
takase1121 81157b5d4f fix memory leak when reproc_start() fails 2021-07-08 11:28:36 +08:00
takase1121 453df84c82 fix bugs with args and env array 2021-07-08 11:21:11 +08:00
takase1121 b38add8de5 move arg checking code to the top 2021-07-08 11:20:08 +08:00
takase1121 9e5b6c72a7 replace Process() constructor with process.start()
fixes wrong metatable and removes redundancy writing
process.Process()
2021-07-08 11:15:02 +08:00
takase1121 b07d37b89a Merge branch 'dev' of github.com:lite-xl/lite-xl into process-refactor 2021-07-07 14:46:49 +08:00
takase1121 420bc2d88a Merge branch 'master' of github.com:lite-xl/lite-xl into dev 2021-07-07 14:46:22 +08:00
takase1121 0059b4a1cc remove duplicated constants 2021-07-07 12:37:07 +08:00
takase1121 8e9034b965 Merge branch 'process-refactor' of github.com:lite-xl/lite-xl into process-refactor 2021-07-07 01:18:52 +08:00
takase1121 116109f069 move constants to the process table
reduce code clutter because they're already namespaced
2021-07-07 01:17:11 +08:00
Takase 57fca752a2
Merge branch 'dev' into process-refactor 2021-07-06 17:16:07 +08:00
takase1121 ccbf676f50 major refactor to the process API
- process.new() is replaced by the Process class
- Process() accepts redirection options and environment variables
- Process:read() does not accept `tries`
- Process:read_stdout() and process:read_stderr() is introduced
- Process:read() now accepts stream as it's first parameter
- Process:running() actually detects if process is running
- Process.returncode() returns the exit code (or exit SIGNAL on POSIX when available)
- constants are moved to process.constants
- process_t.L is removed
2021-07-06 17:00:41 +08:00
Adam 9126b5e64d
Merge pull request #313 from jgmdev/add-system-rmdir
Added `system.rmdir(path)`, and `common.rm(path, recursive)`
2021-06-29 17:44:58 -04:00
jgmdev 4188269cef Added system.rmdir(path)
It is reported that the built-in lua function os.remove(path) does
not removes empty directories on windows. To fix this a system.rmdir
function is introduced that calls a native win32 function.

Also common.rm(path, recursively) was added which wraps system.rmdir()
to easily delete an entire folder with all its contents.
2021-06-28 11:07:27 -04:00
takase1121 79581b551b change double quotes to single quotes to reduce escaping 2021-06-27 23:14:48 +08:00
redtide df63775dca Use lite-xl as project and exacutable names 2021-06-25 22:54:02 +02:00
redtide 3f58e554ba Reorganization of data resources 2021-06-24 22:53:14 +02:00
Adam 83a604dfb7
Merge pull request #296 from lite-xl/font-copy-api
Add a C API copy method for font_desc objects
2021-06-24 12:47:16 -04:00
takase1121 022f92bcd4 do not terminate process when read fails 2021-06-24 16:01:45 +08:00
takase1121 9fa43dbdcb Merge branch 'master' of github.com:lite-xl/lite-xl into dev 2021-06-23 18:37:15 +08:00
takase1121 257cb47cd1 fix wrongly spaced variable name 2021-06-23 18:29:38 +08:00
takase1121 ab0bdd5017 add generic read function
process_read and process_read_errors no longer contain redundant code
2021-06-23 18:23:19 +08:00
takase1121 b5e9e2a7bc refactor process.c
- include api.h instead of individual #includes
- moved metatable name to API_TYPE_PROCESS
- moved read buffer size to READ_BUF_SIZE
2021-06-23 18:21:36 +08:00
jgmdev 88704c6ecb [api/process] added missing fields and minor fix to pid() 2021-06-22 15:01:30 -04:00
Francesco Abbate 1cf0f2009c Add a C API copy method for font_desc objects
Add a renderer.font's method "copy" to clone the font object
by specifying an optional new size. In the size is not given
the size of the original object is used.

Should fulfill the request from issue #288.
2021-06-21 11:18:52 +02:00
jgmdev 5d2734de81 Merge reproc changes from dev. 2021-06-18 14:19:09 -04:00
lqdev 6195b246a5 ignore SIGPIPE from subprocesses spawned with reproc 2021-06-18 11:17:36 -04:00
jgmdev 5d95d604a9 Merge branch 'master' into dev 2021-06-12 23:11:35 -04:00
Adam 804429e3b6
Merge pull request #266 from adamharrison/QuickOptimization
Replaced fill loop with SDL_FillRect.
2021-06-12 22:53:14 -04:00
Francesco Abbate 0f2ac136d0 Fix whitespace errors 2021-06-11 15:02:15 +02:00
Francesco Abbate 752ecd5ece Group mouse move events from C API function
Groups together consecutive mouse move events like done in core.step()
lua function but on the C side.

It does not introduce any meaningful speedup but it theory is more efficient and
simplifies the Lua code.

The simplification of the Lua code alone is enough to justify this change?
2021-06-11 15:00:18 +02:00
Adam Harrison 214e6898df Reverted if guard. 2021-06-09 19:34:02 -04:00
Adam Harrison aa9f16c74c Added in #if guard for ARM achitectures. 2021-06-09 18:05:39 -04:00
Adam Harrison 29837d0c41 Replaced fill loop with SDL_FillRect. 2021-06-08 21:31:09 -04:00
jgmdev a31e683281 Merge branch 'master' into dev 2021-06-06 01:37:01 -04:00
Adam Harrison 3b816a2b4a Changed regex error handling, so that errors can be handled gracefully in lua, and made it so gsub returns the exact matches and replacements. 2021-06-04 23:58:17 -04:00
Francesco b046afccf9
Scale fonts context menu (#246)
* Retrieve scale plugin from lite-plugins

* New implementation of scale plugin and font C API

Introduce two new C API functions, renderer.font.get_size and set_size
respectively to get the font size and to set the size to a new value.

Using these functions we don't need to know the name of the font but
we can just change their size.

Adapt the scale plugin to use the new C API function with minor adaptations
in the logic.

Use smaller step to scale fonts.

Rename font_desc_free function, previous name was misleading as only the cached
resources are freed.

* Add contextmenu plugin from takase

From https://github.com/takase1121/lite-contextmenu

Adapted to show font scaling commands and find/replace commands.

i#	testing.lua

* Fix the cursor flickering with contextmenu

To avoid flickering of the cursor when using the context menu
we add a new function `core.request_cursor` that just take note
of the cursor requested.

The cursor will be actually changed only in root_view:draw() method
only when all the drawing operations are done. This means the cursor
will be changed only once per frame and only the most recent cursor
change request will take effect.

* Remove unneeded scale plugin return functions
2021-06-03 22:49:37 +02:00
Ferdinand Prantl d0adb748a6
Flush the SDL_QUIT event when Cmd+W is detected in SDL_KEYDOWN as well (#248)
On macos 11.2.3 with sdl 2.0.14 the keyup handler for cmd+w was not
enough. Maybe the quit event started to be triggered from the keydown
handler? In any case, flushing the quit event there too helped.
2021-06-03 22:14:50 +02:00
Ferdinand Prantl 1eabf99054
Enable lite-xl to be started from a symlink to the deployed binary (#249)
Use resolved executablePath instead of resourcePath to allow lanching
the lite-xl binary via a symlink, like typically done by Homebrew:

/usr/local/bin/lite-xl -> /Applications/lite-xl.app/Contents/MacOS/lite-xl

The resourcePath returns /usr/local in this case instead of
/Applications/lite-xl.app/Contents/Resources, which makes later
access to the resource files fail. Resolving the symlink to the
executable and then the relative path to the expected directory
Resources is a workaround for starting the application from both
the launcher directly and the command line via the symlink.
2021-06-03 21:48:15 +02:00
Adam 248d70a8ca
Add PCRE to support regular expressions
Use regular expressions instead of Lua patterns for find and replace editor commands.

Syntax files can now use regex or Lua patterns as before keeping backward compatibility for plugins.
2021-06-02 21:27:00 +02:00
lqdev cffcb77726 ignore SIGPIPE from subprocesses spawned with reproc 2021-06-02 17:27:40 +02:00
Francesco Abbate fbbe6d5dfb Merge branch master into dev 2021-05-22 15:12:05 +02:00
Francesco Abbate aa0b2bb5fc Fix crash problem with rencache and font access
In some cases rencache was using a FontDesc pointer that was actually freed by
Lua giving segfaults errors.

In addition, some FontDesc object were not freed in some cases if the
rencache_end_frame was not called when performing the "restart" command.

The invalid access problem can happen because rencache keep some pointers to
FontDesc object but these are Lua userdata that Lua can dispose of. This
situation is prone to hard errors and we should avoid to keep pointers to
objects managed by Lua.

To this purpose we use luaL_ref/unref to bind the FontDesc into the Lua's
registry while rencache need them. We still keeps pointer to FontDesc object but
using luaL_ref we are assured they will not be disposed by Lua.

Since we are using luaL_ref/unref to inform the GC about when the objects are in
use we can now finalize the objects directly when Lua collects them. Previously
the GC metamethods was issuing a FREE command to rencache and the font was
actually freed only from the rencache_end_frame function.
2021-05-21 23:38:54 +02:00
Francesco Abbate 84095fadc9 Merge branch master into dev 2021-05-20 13:51:35 +02:00
Francesco Abbate 60219007f1 Fix include for reproc header 2021-05-20 13:50:13 +02:00
Francesco Abbate a8e1e040ca Meson config to use reproc as external library 2021-05-20 13:40:11 +02:00
jgmdev 9b1b1a3820 Initial work to allow writing LSP client in LUA.
* Added an amalgamated C version of https://github.com/DaanDeMeyer/reproc
* Added lua binding of reproc accesible in the process package.
* Modified meson build to include reproc sources as src/api/process.c
2021-05-20 13:39:07 +02:00
Adam c7b1a6f53e
Allowed for optional boolean to better match filenames. (#180) 2021-05-16 19:23:17 +02:00
Adam Harrison c0c6bc5be9 Replaced pattern-based commands with regexes. 2021-05-06 19:53:03 -04:00
Francesco Abbate b3f9faff4a Fix pcre2 meson build config 2021-05-06 19:53:03 -04:00