Commit Graph

154 Commits

Author SHA1 Message Date
Takase 49cde08ed6
Use Xlib to read resources (#142) 2021-04-02 16:43:21 +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 e160ed4e5e Add comments about unused RenFont data field 2021-03-20 23:05:09 +01:00
Francesco Abbate b33167ca4b Revert "Remove unused data field in RenFont"
This reverts commit 461266e97d.

Related to github issue #122.

The void *data field is not used but the glyphset index can
someting be equal to -1 and the unused field prevent faulty
writes before the allocated struct.
2021-03-20 21:48:04 +01:00
Francesco Abbate aee602ea2f Merge branch 'xrdb-lean' 2021-03-18 16:20:32 +01:00
Francesco Abbate 461266e97d Remove unused data field in RenFont 2021-03-18 14:05:58 +01:00
Francesco Abbate ecb9e88fdb Merge branch 'master' into xrdb-lean 2021-03-18 14:00:54 +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 a742c56ee7 Minor xrdb buffer optimization 2021-03-18 10:06:01 +01:00
Francesco Abbate 43e08b0f8e Fix problem with previous commit and remove strtol call 2021-03-18 10:00:03 +01:00
Francesco Abbate 51e7c9493f Minor change for xrdb output parsing
Use memmove to copy remaining bytes at beginning of buffer
2021-03-18 09:32:52 +01:00
Francesco Abbate ac0728d073 Check for error in pipe call 2021-03-17 18:29:50 +01:00
Francesco Abbate 30f9f20e23 Ensure xrdb code is compiled only on unix 2021-03-17 18:10:47 +01:00
Francesco Abbate dab39d3b5c Implement xrdb reading without popen
Avoid using the shell, awk and cut command
2021-03-17 16:58:44 +01:00
daubaris 27f3cb23d4
Addressing the scaling factor on linux. (#107)
Use xrdb and the Xft.dpi variable to find out DPI scaling on linux.
2021-03-14 16:13:26 +01:00
Francesco Abbate baf5aebe1c Merge remote-tracking branch 'origin/master' into subpixel-font-positioning-fix 2021-03-07 12:25:53 +01:00
Francesco Abbate 23a053e1ee Ensure error and stack trace are written to stdout
To address https://github.com/franko/lite-xl/issues/87
2021-03-07 09:48:44 +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 09332fe242 Fix problem with fatal error message
Previous implementation was broken.

Ensure the error file is always written and write its location in the error message
2021-03-05 23:46:41 +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 636bc7ec95 More accurate EXEDIR detection
Use ony the OS path separator to parse the executable filename
2021-03-05 09:42:48 +01:00
Francesco Abbate ffb4773a0b Merge branch 'subpixel-font-positioning' 2021-03-05 09:14:25 +01:00
Francesco Abbate 1ea497deb4 Fix problem when launching from a different location
Should fix https://github.com/franko/lite-xl/issues/76 and https://github.com/franko/lite-xl/issues/67
2021-03-05 07:28:29 +01:00
Francesco Abbate 294f3f14fb Implement subpixel font positioning
Subpixel positioning is only by 1/3 of pixel
2021-03-03 18:36:09 +01:00
Francesco Abbate 351a772466 do not use 'portable' as a compile time option
Introduce the file core/start.lua to initialize applications variables
2021-02-24 16:29:39 +01:00
Francesco Abbate ea8a8770ea Do not use nullptr and add check 2021-02-24 09:46:48 +01:00
Francesco Abbate 35f31c8fbc Fix font rendering artifacts bug
Seen with some fonts like FiraSans, github issue:

https://github.com/franko/lite-xl/issues/46

The fix works essentially by looking to the bounds of each glyph to
accurately ensure that there are no overlaps between the glyphs.

The construction of the font atlas was changed to make some related
improvements now that the bounds of each glyph are know. The main
changes are:

- no longer align glyph on the baseline but align them on their upper
  bounds. We ensure this way that very tall fonts do not leak in the
  upper part
- terminate the row based on x bounds of the glyph to be more accurate
- for each row keep trace of the y of the more larger along y of the
  glyph. The value is used to start a new row to be sure that the new
  now does not overlap with the previous one
- sort glyphs by y size before drawing them. In this way the space
  utilization is better. The algorithm used is the very simple insert
  sort. It behaves like O(n^2) with the number of characters but should
  be ok since n is always small, typically below 128.
- compute the optimal image width and height for the given font's atlas
  for optimal memory usage. As a bonus now the lite's code don't have to
  try and repeat to get a good image size
2021-02-23 17:14:08 +01:00
Francesco Abbate 9fced84a7a Move VERSION variable into Lua code
To avoid recreating binaries if there are no changes
in the C side of the source code.
2021-02-16 14:35:02 +01:00
Francesco Abbate 882413e92d Bump 1.16 version number 2021-01-13 16:52:27 +01:00
Francesco Abbate d3686bb6f4 Bump new version number 2020-12-31 11:27:35 +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 35c87462a6 Use ~ for HOME directory in folder search 2020-12-19 16:31:42 +01:00
Francesco Abbate e50d67df85 Update readme and changelog for release 1.14 2020-12-13 13:04:29 +01:00
Francesco Abbate 1fc0409163 Merge branch 'project-manager' 2020-12-12 20:27:07 +01:00
Francesco Abbate 6409b67ea2 Add core:restart function to restart the editor 2020-12-10 12:44:01 +01:00
Francesco Abbate 1c4b8cf315 Fix documentation and behavior for 1.13 release 2020-12-06 11:23:33 +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 be189fda0d Always use HOME based user's config independently from portable option 2020-12-04 12:01:49 +01:00
Francesco Abbate c41dedafad Improve the implementation of unix-like directories usage
Add a Meson option "portable" to choose between "portable" and unix-like
directories. Add information about this option in the README.

To determine the user's directory use the variable USERPROFILE only on
Windows and use HOME otherwise.

Implement the "portable" option in the package build script.
2020-12-03 16:46:18 +01:00
Francesco Abbate 277186491a Fix some problems with user's directory
To accommodate the Window's platform prefer the USERPROFILE to HOME
to set user's dir.

Fix error, user's dir was not added to the package.path.
2020-12-02 16:43:35 +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 3589d7d3c0 First implementation of unix-like data directory
It basically works by setting the data directory to

$prefix/share/lite-xl

where $prefix is determined so that $prefix/bin corresponds to EXEDIR.

The packages 'user' and 'user.*' are loaded from the directory
'$HOME/.config/lite-xl'.
2020-12-02 00:23:15 +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 cdcd89d6d7 Merge remote-tracking branch 'rxi/master' 2020-11-17 10:24:27 +01:00
rxi 878c94a334 Changed rencache to store font tab_width with font command
Fixes bug where text would be drawn/cached wrongly if more than one tab_width
was used in a given frame
2020-09-05 15:09:54 +01:00
Francesco Abbate 1c5767d393 Merge remote-tracking branch 'rxi/master' 2020-08-19 10:08:32 +02:00
rxi 91c43dc01e Version 1.11 2020-07-05 10:56:39 +01:00
Francesco Abbate 14ec61511d Merge remote-tracking branch 'rxi/master' 2020-07-04 22:08:25 +02:00