Commit Graph

48 Commits

Author SHA1 Message Date
George Sokianos 4499f1f111 Some code cleanup and added .config folder to gitignore 2021-12-26 17:08:09 +00:00
George Sokianos c155f797cf First commit of compilable code for OS4 2021-12-21 17:52:44 +00:00
Francesco Abbate 2af92e9af1 Fix whitespace errors 2021-06-17 23:31:44 +02:00
Francesco Abbate 704a8dea09 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-17 23:31:44 +02:00
Ferdinand Prantl 2365dfa9c0 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-17 23:31:44 +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
Adam c7b1a6f53e
Allowed for optional boolean to better match filenames. (#180) 2021-05-16 19:23:17 +02:00
Francesco Abbate 3d84fe5488 Make usage of SDL renderer optional 2021-04-29 14:15:24 +02:00
Francesco Abbate f2a33a567b Cleanup FontDesc struct and implementation 2021-04-26 15:56:18 +02:00
Francesco Abbate 46c3bdea67 First implementation of scaling for retina display
Introduce a new approach that discriminate coordinates in
points and pixels. Now all the logic from the Lua side and in
rencache is to always use points. The coordinates are converted
to pixels only within the renderer, in the file renderer.c.
In this way the application logic does not need to care about the
scaling of the retina displays.

For non-retina display the scaling between points and pixels is
equal to one so nothing will change.

There is nevertheless a change that leak into the Lua side. The
subpixel coordinates are in sub-pixel, not sub-points so they are
scaled by the retina scaling factor. But no change in the code is
required because the subpixel scaling factor take into account the
retina scaling, when present.

Because the retina scaling factor is not know when the application
starts but only when a window is actually available we introduce a
mechanism to render the font with a given scaling factor only from
the renderer when they are needed. We use therefore FontDesc to
describe the font information but without actually rasterizing the
font at a given scale.
2021-04-26 15:16:34 +02:00
Francesco Abbate 57e6de978b Fix error with missing ren_resize call 2021-04-23 07:09:50 -07:00
Francesco Abbate 33fe7295c0 First working implemention
Cleanup also debug messages
2021-04-23 14:54:25 +02:00
Francesco Abbate 1f6680b492 Add macos flush specific fix
Taken from @mathewmariani lite-macos
2021-04-21 09:51:40 +02:00
Francesco Abbate d5e9ef6bff Remove trailing debug message 2021-04-12 19:12:21 +02:00
Francesco Abbate f7375924ab Make non-borderless mode work 2021-04-12 19:05:30 +02:00
Francesco Abbate 4de97d51fb Avoid always calling system.get_window_mode 2021-04-12 13:31:32 +02:00
Francesco Abbate 46791aefe5 Implement maximize/restore controls
Remove also resize from top and right of the window
2021-04-12 11:54:52 +02:00
Francesco Abbate 67dc16ad26 Make windows control buttons active 2021-04-11 23:52:31 +02:00
Francesco Abbate 8ad87d77da Add correct hit-test information and menu icon 2021-04-11 15:08:25 +02:00
Francesco Abbate 7531a0ddc8 Preliminary implementation of border-less mode
Not yet functional but most ingredients are there
2021-04-10 19:35:57 +02:00
Francesco Abbate b1c1deb4c4 Remove no longer used system.show_confirm_dialog
Replaced by the NagView dialog
2021-04-06 07:12:33 +02:00
Francesco Abbate 3b040aabc7 Implement unicode character replacements
Useful to draw whitespaces with alternate characters and colors
without slowing down the text rendering.

A new API is implemented. A renderer.replacements object can be created
to list the replacements.

In turns the function renderer.draw_text and draw_text_subpixel now accept
two optional arguments for replacements.
2021-04-01 18:05:59 +02:00
Francesco Abbate 4b3b8f430a Merge remote-tracking branch 'basinbaby/set-window-opacity'
Implement the suggestion and close #125.

Initial suggestion and implementation from

https://github.com/rxi/lite/pull/17
2021-03-23 07:15:18 +01:00
Francesco Abbate 88bec172a1 Fix problem with tab size and subpixel positioning
Solve github issue https://github.com/franko/lite-xl/issues/109
2021-03-18 13:54:33 +01:00
Francesco Abbate 3426bc5d73 Introduce subpixel text positioning within rencache
In order to fix the issue with cursor positioning a subpixel-aware draw
text operation within rencache was required.

With this modification the cursor positioning problem is completely
resolved.

A new function renderer.draw_text_subpixel is introduced to perform
consecutive, inline, text drawings with subpixel accuracy.
2021-03-06 18:12:02 +01:00
Francesco Abbate 9ff6a0325e Mostly fix problem of offset with cursor positioning when using mouse
In order to get right the cursor position on text on mouse clicks it is
needed to take into account text's subpixel positioning.

This fix mostly corrects the problem but cursor positioning is still
somewhat inaccurate for long lines due to repeated commands to draw a text
along a line. Repeated draw text calls make the subpixel information
lost and small errors will add-up.
2021-03-06 16:18:24 +01:00
Francesco Abbate a4bc8986ff Implement fatal error message box
Used when lite-xl fails at startup
2021-03-05 10:33:50 +01:00
Francesco Abbate 2cdf674b97 Keep memory of window's size and position and restore them on start
Fix also a problem with directory path on windows.
2020-12-31 11:25:12 +01:00
Francesco Abbate afda299fe4 Implement optional font rendering options
The user can now choose antialiasing grayscale and subpixel and hinting
non, slight or full.
2020-12-04 16:15:54 +01:00
Francesco Abbate a337f893d9 Implement user's config as init file and add directory into package.path
Create the user's config init file if lite user's config directory does
not exists.

No longer use the awkward package.searchers but instead add user's
config dir at the end of package path.
2020-12-02 16:03:31 +01:00
Francesco Abbate 70412b520b Fix cursor blinking problem
The problem was that when the editor had no events the cursor was not
blinking because the event loop was blocking on wait_event.

Now we no longer calls wait_event without a timeout if the windows has
the focus. When the window has the focus the timeout is set to 1 / fps
so that the cursor can blinks.

In addition we react to the "focus lost" event to ensure the documents
are redrawn without the cursor.
2020-11-21 16:36:32 +01:00
Francesco Abbate 77a9819f4e Fix SDL2 include directives 2020-06-29 15:24:08 +02:00
Francesco Abbate 5c3d4163d3 Modify system.wait_event to wait indefinitely if no timeout is given 2020-06-16 14:53:01 +02:00
Francesco Abbate 618078829c Add meson build configuration
Currently the editor will not work if it is not installed.

There is also a caveat about the 'data' directory which is installed
in the bin directory. This may work but does not seem ok because it is
pollution a shared bin directory and the 'data' folder may not be unique
to Lite.
2020-05-25 12:22:23 +02:00
rxi 61092fbb99 Changed fuzzy matching to favour matching case 2020-05-23 15:08:38 +01:00
rxi 35b642d434 Added rencache invalidation on window-exposed event
Fixes #63
2020-05-22 09:00:48 +01:00
rxi 35ce3d32a9 Fixed string quoting on windows in `system.exec()` 2020-05-22 08:11:05 +01:00
rxi 7aabfebfa0 Fixed mouse-position resolution when dropping a file 2020-05-20 10:33:08 +01:00
rxi 4ae0d477c0 Made lite set project dir to CWD; removed core.project_dir
Fixes #100
2020-05-17 17:05:56 +01:00
rxi 2b32edf7f0 Added system.exec() to system api 2020-05-13 20:32:53 +01:00
rxi c215eff6d8 Improved idle CPU utilisation when not-focused, added system.wait_event() 2020-05-11 00:21:07 +01:00
rxi b2756d8a49 Removed xalloc.c/h 2020-05-08 13:41:39 +01:00
rxi 03eee86ddb Made font.gc() do null-check in case font.load() failed 2020-04-22 00:41:23 +01:00
rxi a9b4bdf602 Made system.get_file_info() and list_dir() return (nil,msg) on error 2020-04-21 23:33:04 +01:00
rxi d4284edd5c Replaced system.set_fullscreen with system.set_window_mode
Solves #24
2020-04-07 18:49:11 +01:00
rxi efed38d59c Added system.set_fullscreen() and core:toggle-fullscreen command 2020-03-25 22:44:59 +00:00
basinbaby f37f22fb5f Added set_window_opacity function 2020-02-07 13:01:56 +00:00
rxi d8c4bfa6ba Initial commit 2019-12-28 11:17:56 +00:00