Commit Graph

486 Commits

Author SHA1 Message Date
Takase 8090c1aa29
process: fix unitialized variables (#1719)
* process: fix potential unitialized variables

* process: fix brace initializer error on Windows
2024-02-05 09:23:24 -05:00
Chloé Vulquin 1a5fd97c20
Add system.setenv (#1706)
* add system.setenv

* document system.setenv

* system.setenv: use wide versions of functions on windows

* do not include processenv.h

* system.setenv: report failure, including of utfconv

* system.setenv: free utfconv output
2024-01-23 00:22:44 +01:00
Takase 0383e17475
process: style changes (#1709) 2024-01-21 10:18:32 +08:00
Chloé Vulquin e9a8dff884
Memory fixes (#1705)
* fix: free-before-init in renwin_init_surface when using sdl renderer

`ren->rensurface.surface` presupposes zero-initialized rensurface.
Rensurface was not actually zero-initialized.
It is now.

* fix: heap buffer overflow in process_env_free

`process_env_free` presupposed that it was null-terminated.
Pass length to free instead.

* use calloc instead of memset for zero-init

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>

---------

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
2024-01-20 08:02:46 +08:00
Jan badcaef13b
turn window_renderer into managed pointer (#1683)
* turn window_renderer into managed pointer
this will make it easier to move it into userdata in the future

* remove unused function, remove comment
2023-12-06 12:51:45 +01:00
Takase 142f0a17ba
feat(process): allow commands and envs on proces_start (#1477)
* feat(process): allow commands and envs on proces_start

* refactor(process): copy process arguments once whenever possible

Refactors the code to use an arglist type which is just lpCmdline on Windows
and a list in Linux.
The function automatically escapes the command when it is needed, avoiding
a second copy.

This also allows UTF-8 commands btw.

* fix(process): fix invalid dereference

* refactor(process): mark xstrdup as potentially unused

* feat(process): add parent process environment when launching process

* fix(process): fix operator precedence with array operators

* fix(process): fix segfault when freeing random memory

* fix(process): fix wrong check for setenv()

* fix(process): fix accidentally initializing an array by assignment

* fix(process): clear return value if success
2023-11-30 10:33:24 -05:00
Guldoman 3575898e62
Use x offset to define render command rect in `rencache_draw_text` (#1618)
* Return x offset for the first character in `ren_font_group_get_width`

* Use x offset to define render command rect in `rencache_draw_text`
2023-11-29 15:44:48 -05:00
Guldoman 8fd76d5d5c
Scale mouse coordinates by window scale (#1630)
* Update window scale on resize

* Scale mouse coordinates by window scale

* Avoid scaling mouse coordinates while using `LITE_USE_SDL_RENDERER`
2023-11-29 10:21:58 -05:00
Guldoman baa0c16e4d
Fix `dirmonitor` sorting issues (#1599)
* Use `PATHSEP` in path-related functions

* Don't stop on digits when getting the common part in `system.path_compare`

* Avoid sorting multiple times in `dirwatch.get_directory_files`

This also fixes the timeout detection in `recurse_pred`.
2023-11-29 09:55:38 -05:00
Guldoman a0ef2906a1
Limit `system.{sleep,wait_event}` to timeouts >= 0 (#1666)
Otherwise we might wait forever by mistake.
2023-11-29 09:07:33 +08:00
Takase 1620a92d54
fix(dirmonitor): deadlock if error handler jumps somewhere else (#1647)
* fix: deadlock if error handler jumps somewhere else

* docs(dirmonitor): fix wrong data type in error callback

* docs(dirmonitor): clarify coroutines and deadlocks

* docs(dirmonitor): wording

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>

---------

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
2023-10-21 19:17:49 +02:00
Guldoman 8a1a34c1ff
Set SDL hint to prefer software render driver (#1646) 2023-10-21 08:16:32 +02:00
Takase 5a5674d130
fix: dim rendering when antialiasing is turned off (#1641) 2023-10-14 16:16:36 -04:00
Guldoman 57dffbaf2a
Remove DPI detection for default `SCALE`
This often leads to `SCALE` values that are way off, and makes Lite XL 
unusable, so we now just default it to 1.
2023-09-30 16:48:38 +02:00
Takase a867beffdd
feat(src/renderer): unify fontgroup baseline (#1560)
* feat(src/renderer): unify fontgroup baseline

* fix(src/renderer): use the first font's baseline for the text run
2023-08-03 20:03:33 +02:00
Takase 76f23a2dc9
feat(src/renderer): stream fonts with SDL_RWops on all platforms (#1555)
* feat(src/renderer): stream fonts with SDL_RWops on all platforms

This fixes #1529 where the font itself carries the font file, which gets copied around.
This commit streams the file, so the file is not entirely in memory.

* style(src/renderer): use standard C types

* refactor(src/renderer): implement FT_Stream.close

* fix(src/renderer): fix SDL_RWops double free
2023-07-10 21:45:36 -04:00
Takase 99d72eaebd
style(src/renderer): use FreeType header names (#1554) 2023-07-09 02:42:40 +02:00
Guldoman f52f017424
Allow setting custom glyphset size (#1542)
* Properly set glyphset size

* Rename `MAX_GLYPHSET` to `GLYPHSET_SIZE`

* Use more appropriate types for font metrics
2023-07-03 23:50:28 -04:00
Jan dfaa7be4cc
Attach command buffer to Renderer Window (#1472) 2023-06-16 16:19:52 +02:00
Guldoman 8e71d3f050
Increase number of loadable glyphsets (#1524)
This should be enough to load every unicode codepoint.
2023-06-13 16:45:43 -04:00
Jefferson González 77f412e7e8
Close lua state when exiting on a runtime error (#1487)
* Close lua state when exiting on a runtime error

* This change allows calling the garbage collector before exiting the
  application for a cleaner shutdown.
* Components like the shared memory object on #1486 will have a better
  chance at destroying no longer needed resources.

* Overriden os.exit to always close the state

* Allow setting close param on os.exit override

* Simplified the os.exit override a bit more

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>

---------

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
2023-05-19 13:28:39 -04:00
takase1121 37b6803094
fix(renderer): fix memory leak when freeing glyphsets 2023-05-16 21:18:04 +08:00
takase1121 83399280f5
fix(rencache): fix compiler warning for printing size_t 2023-04-23 16:44:07 +08:00
Takase 246d4fc93f
fix(process): check for HANDLE_INVALID (#1475) 2023-04-18 21:02:10 -04:00
Jan 76ec16f299
Make `system.path_compare` more digit-aware (#1474)
This allows a human friendly sorting filenames with numbers in them
So
- asd1
- asd10
- asd2
becomes
- asd1
- asd2
- asd10
2023-04-18 14:55:25 -04:00
Takase a3a1c5d069
Process API improvements (again) (#1370)
* feat(process): add push_error
* refactor(process): use push_error for better errors
* style(process): consistent error messages
* refactor(process): reimplement process.strerror() with push_error
* refactor(process): implement close_fd only once
* refactor(process): rename process_handle to process_handle_t
* fix(process): prevent errors from a NULL error message
* refactor(process): refactor push_error into 2 functions
* fix(process): fix wrong error message
* fix(process): check if push_error_string actually pushed something
* refactor(process): make error messages descriptive
* fix(process): check for empty table instead of aborting
* refactor(process): make error messages descriptive on Windows
* refactor(process): rename process_stream_handle to process_stream_t
* refactor(process): fix wrong usage of process_handle_t
* fix(process): fix wrong type name
* refactor(process): incoporate kill_list_thread into process_kill_list_t
* refactor(process): make kill_list per-state data
2023-04-17 14:56:04 -04:00
Guldoman 80876ebc7c
Show error message in crash message box (#1461)
* Save to `error.txt` the same traceback shown on stdout
* Show error message in crash message box
2023-04-14 15:22:22 -04:00
Jefferson González d4bf839b3d
Fix for api_require wrong macro && conditions (#1465)
This mistake escaped my eyes when reviewing #1437 and causes
some symbols to not be exported, because the preprocessor macros
are expecting multiple LUA versions to evaluate as true at once.
The fix is to replace `&&` with `||`.
2023-04-11 03:29:31 +02:00
Guldoman 6d4bf4ff90
Make `system.path_compare` more case-aware (#1457)
* Use Lua-provided string lengths for `system.path_compare`
* Make `system.path_compare` more case-aware
   Before, strings like `README.md` would be sorted before `changelog.md`, 
   because we only looked at the raw ascii values.
   Now the character case is considered as a secondary sorting key.
2023-04-07 14:41:32 -04:00
Takase 4b97752301
Update api_require to expose more symbols (#1437)
* feat(system): update api_require for more symbols
* fix(system): fix missing 5.1 symbols
* fix(system): add more missing symbols
* fix(system): add all symbols
   We got'em this time. I swear.
* fix(system): fix undefined symbols due to conditional compilation
   There is only pain and suffering.
   Turns out some of the symbols are only exported when the options are enabled.
   We need to preprocess the header.
2023-04-07 13:45:28 -04:00
Takase 6313b3d274
fix: fix differing stacktrace on stdout and file (#1404)
* fix(c-bootstrap): produce identical stack traces
2023-04-07 13:18:16 -04:00
Takase ecb599e61b
Fix invalid EXEFILE and EXEDIR on Windows (#1396)
* fix(main): fix get_exe_filename returning invalid result on Windows
* fix(main): fix bootstrap not intepreting UTF-8 properly
2023-04-07 13:06:01 -04:00
Adam a0de8ea81d
Added in support for foreground and background events. (#1395) 2023-04-07 12:58:56 -04:00
Adam 1a0d3a4a03
Added in explicit touchscreen keyboard support. (#1389) 2023-04-07 12:42:46 -04:00
Takase 0cacaf940b
Asynchronous process reaping (#1412)
* refactor(process): introduce process_stream_handle separate from process_handle

* feat(process): introduce process_handle helper functions

* feat(process): add asynchronous process reaping

* feat(process): wait for shorter period if possible

* style(process): remove unecessary brackets

* style(process): fix parentheses

* refactor(process): remove useless setvbuf call

* style(process): remove unecessary value

* refactor(process): add size field into kill_list

* refactor(process): use SDL_Delay for sleeping

* style(process): remove trailing whitespace

* fix(main): destroy window before closing lua

* fix(process): check for timeout correctly

* refactor(process): remove unecessary if check

* refactor(process): remove size from the list

* fix(process): fix invalid delay calculation

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>

---------

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
2023-03-22 13:36:05 +01:00
Guldoman 2cdf5d8949
Aggregate `SDL_Surface`s and their scale in `RenSurface` (#1429) 2023-03-19 15:39:52 -04:00
Guldoman 18720665d2
Use clipping functions provided by SDL (#1426) 2023-03-14 11:39:00 -04:00
Guldoman ed9bb3c85d
Improve text width calculation precision (#1408)
In some extreme cases (~30000 chars) text width precision takes a hit.
Using double instead of float fixes that.
2023-03-09 10:48:46 -05:00
Takase 1e990bdfdc
refactor(main): move SetProcessDPIAware to manifests (#1413) 2023-03-09 14:58:32 +01:00
Guldoman 73f3cd4fcd
Split `Command` struct into different structs for each command type (#1407)
This reduces the space needed for each command.
2023-03-04 15:23:09 -05:00
Takase aad52fc679
Add manifest on Windows (#1405)
* fix(gitignore): add exclusion for manifest files

* feat(windows): add application manifest

* feat(build): use application manifest on windows

* refactor(build): use genrate_file to generate the manifest

* style(manifest): remove trailing whitespace
2023-03-03 15:07:45 +01:00
Adam 2035886fcd
Added in ability to specify prefix via env variable. (#1388) 2023-02-15 21:48:09 -04:00
Takase 9d7a9ac564
fix: exec() error not returned to parent (#1363)
* fix: exec() error not returned to parent

* chore: remove accidental lua.h inclusion
2023-01-31 17:26:15 -05:00
Jan 36cb0e6425
pass RenWindow by argument (#1321)
* pass RenWindow to all renderer functions that need it

* pass RenWindow to all rencache functions that need it
2023-01-21 22:11:42 -05:00
Guldoman 9308dfdd66
Avoid drawing hidden text in `DocView:draw_line_text` (#1298)
* Stop drawing text past the `DocView` edge in `DocView:draw_line_text`

* Don't add draw commands if they fall outside the latest clip

The check was previously done with the window rect, so this will reduce 
a bit more the number of commands sent.
2023-01-18 22:15:26 -05:00
Adam Harrison 283ee8520a Updated dummy method signature to match prototypes. 2023-01-13 16:31:28 -05:00
Guldoman b89dedf566
Make empty groups in `regex.gmatch` return their offset (#1325)
This makes `regex.gmatch` behave like `string.gmatch`.
2023-01-13 19:34:09 +01:00
adityaraj f9933ed621
Create Renderer Only When It Doesn't Exist (#1315) 2023-01-11 18:53:23 -05:00
Jan bebef68d97
replace uses of SDL_Window with RenWindow (#1319)
Since Renwindow contains our instance of SDL_Window we can use this
to simplify future logic to create separate window instances
2023-01-11 18:25:06 -05:00
Jan aa503665e0
defer lua error until after cleanup (#1310) 2023-01-06 14:31:44 -04:00