aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md10
-rw-r--r--data/core/nagview.lua121
-rw-r--r--data/plugins/autocomplete.lua13
-rw-r--r--data/plugins/workspace.lua12
-rw-r--r--resources/linux/org.lite_xl.lite_xl.appdata.xml4
-rw-r--r--scripts/appimage.sh17
-rw-r--r--scripts/lite-xl-ubuntu-build.yml26
-rw-r--r--scripts/package.sh15
-rw-r--r--scripts/repackage-appimage.sh73
9 files changed, 232 insertions, 59 deletions
diff --git a/changelog.md b/changelog.md
index fef160b6..2417aab8 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,15 @@
This files document the changes done in Lite XL for each release.
+### next release
+
+Improve the NagView to scroll long messages and fix problem with mouse click on
+buttons didn't work. Contributed by @jgmdev.
+
+When loading a project's workspace no longer open views for files which no longer
+exists.
+More often file were deleted by user or removed because changing commit and there
+was no interest opening an empty document for a file that no longer exists.
+
### 2.0.5
Revamp the project's user module so that modifications are immediately applied.
diff --git a/data/core/nagview.lua b/data/core/nagview.lua
index fca6c306..0c9e575e 100644
--- a/data/core/nagview.lua
+++ b/data/core/nagview.lua
@@ -19,6 +19,9 @@ function NagView:new()
self.show_height = 0
self.force_focus = false
self.queue = {}
+ self.scrollable = true
+ self.target_height = 0
+ self.on_mouse_pressed_root = nil
end
function NagView:get_title()
@@ -47,15 +50,15 @@ function NagView:get_target_height()
return self.target_height + 2 * style.padding.y
end
-function NagView:update()
- NagView.super.update(self)
-
- if core.active_view == self and self.title then
- self:move_towards(self, "show_height", self:get_target_height())
- self:move_towards(self, "underline_progress", 1)
+function NagView:get_scrollable_size()
+ local w, h = system.get_window_size()
+ if self.visible and self:get_target_height() > h then
+ self.size.y = h
+ return self:get_target_height()
else
- self:move_towards(self, "show_height", 0)
+ self.size.y = 0
end
+ return 0
end
function NagView:dim_window_content()
@@ -95,6 +98,8 @@ function NagView:each_option()
end
function NagView:on_mouse_moved(mx, my, ...)
+ if not self.visible then return end
+ core.set_active_view(self)
NagView.super.on_mouse_moved(self, mx, my, ...)
for i, _, x,y,w,h in self:each_option() do
if mx >= x and my >= y and mx < x + w and my < y + h then
@@ -104,43 +109,55 @@ function NagView:on_mouse_moved(mx, my, ...)
end
end
--- Used to store saved value for RootView.on_view_mouse_pressed
-local on_view_mouse_pressed
-
-
-local function capture_mouse_pressed(nag_view)
+local function register_mouse_pressed(self)
+ if self.on_mouse_pressed_root then return end
-- RootView is loaded locally to avoid NagView and RootView being
-- mutually recursive
local RootView = require "core.rootview"
- on_view_mouse_pressed = RootView.on_view_mouse_pressed
- RootView.on_view_mouse_pressed = function(button, x, y, clicks)
- local handled = NagView.on_mouse_pressed(nag_view, button, x, y, clicks)
- return handled or on_view_mouse_pressed(button, x, y, clicks)
+ self.on_mouse_pressed_root = RootView.on_mouse_pressed
+ local this = self
+ function RootView:on_mouse_pressed(button, x, y, clicks)
+ if
+ not this:on_mouse_pressed(button, x, y, clicks)
+ then
+ return this.on_mouse_pressed_root(self, button, x, y, clicks)
+ else
+ return true
+ end
end
+ self.new_on_mouse_pressed_root = RootView.on_mouse_pressed
end
-
-local function release_mouse_pressed()
+local function unregister_mouse_pressed(self)
local RootView = require "core.rootview"
- if on_view_mouse_pressed then
- RootView.on_view_mouse_pressed = on_view_mouse_pressed
- on_view_mouse_pressed = nil
+ if
+ self.on_mouse_pressed_root
+ and
+ -- just in case prevent overwriting what something else may
+ -- have overwrote after us, but after testing with various
+ -- plugins this doesn't seems to happen, but just in case
+ self.new_on_mouse_pressed_root == RootView.on_mouse_pressed
+ then
+ RootView.on_mouse_pressed = self.on_mouse_pressed_root
+ self.on_mouse_pressed_root = nil
+ self.new_on_mouse_pressed_root = nil
end
end
-
function NagView:on_mouse_pressed(button, mx, my, clicks)
+ if not self.visible then return false end
if NagView.super.on_mouse_pressed(self, button, mx, my, clicks) then return true end
for i, _, x,y,w,h in self:each_option() do
if mx >= x and my >= y and mx < x + w and my < y + h then
self:change_hovered(i)
command.perform "dialog:select"
- return true
end
end
+ return true
end
function NagView:on_text_input(text)
+ if not self.visible then return end
if text:lower() == "y" then
command.perform "dialog:select-yes"
elseif text:lower() == "n" then
@@ -148,10 +165,25 @@ function NagView:on_text_input(text)
end
end
+function NagView:update()
+ if not self.visible and self.show_height <= 0 then return end
+ NagView.super.update(self)
-local function draw_nagview_message(self)
- if self.show_height <= 0 or not self.title then return end
+ if self.visible and core.active_view == self and self.title then
+ self:move_towards(self, "show_height", self:get_target_height())
+ self:move_towards(self, "underline_progress", 1)
+ else
+ self:move_towards(self, "show_height", 0)
+ if self.show_height <= 0 then
+ self.title = nil
+ self.message = nil
+ self.options = nil
+ self.on_selected = nil
+ end
+ end
+end
+local function draw_nagview_message(self)
self:dim_window_content()
-- draw message's background
@@ -160,6 +192,8 @@ local function draw_nagview_message(self)
ox = ox + style.padding.x
+ core.push_clip_rect(ox, oy, self.size.x, self.show_height)
+
-- if there are other items, show it
if #self.queue > 0 then
local str = string.format("[%d]", #self.queue)
@@ -196,9 +230,16 @@ local function draw_nagview_message(self)
common.draw_text(opt.font, style.nagbar_text, opt.text, "center", fx,fy,fw,fh)
end
+
+ self:draw_scrollbar()
+
+ core.pop_clip_rect()
end
function NagView:draw()
+ if (not self.visible and self.show_height <= 0) or not self.title then
+ return
+ end
core.root_view:defer_draw(draw_nagview_message, self)
end
@@ -210,28 +251,30 @@ function NagView:get_message_height()
return h
end
-
function NagView:next()
local opts = table.remove(self.queue, 1) or {}
- self.title = opts.title
- self.message = opts.message and opts.message .. "\n"
- self.options = opts.options
- self.on_selected = opts.on_selected
- if self.message and self.options then
+ if opts.title and opts.message and opts.options then
+ self.visible = true
+ self.title = opts.title
+ self.message = opts.message and opts.message .. "\n"
+ self.options = opts.options
+ self.on_selected = opts.on_selected
+
local message_height = self:get_message_height()
-- self.target_height is the nagview height needed to display the message and
-- the buttons, excluding the top and bottom padding space.
self.target_height = math.max(message_height, self:get_buttons_height())
self:change_hovered(common.find_index(self.options, "default_yes"))
- end
- self.force_focus = self.message ~= nil
- core.set_active_view(self.message ~= nil and self or
- core.next_active_view or core.last_active_view)
- if self.message ~= nil and self then
+
+ self.force_focus = true
+ core.set_active_view(self)
-- We add a hook to manage all the mouse_pressed events.
- capture_mouse_pressed(self)
+ register_mouse_pressed(self)
else
- release_mouse_pressed()
+ self.force_focus = false
+ core.set_active_view(core.next_active_view or core.last_active_view)
+ self.visible = false
+ unregister_mouse_pressed(self)
end
end
@@ -242,7 +285,7 @@ function NagView:show(title, message, options, on_select)
opts.options = assert(options, "No options")
opts.on_selected = on_select or noop
table.insert(self.queue, opts)
- if #self.queue > 0 and not self.title then self:next() end
+ self:next()
end
return NagView
diff --git a/data/plugins/autocomplete.lua b/data/plugins/autocomplete.lua
index fde9487e..0d3058b7 100644
--- a/data/plugins/autocomplete.lua
+++ b/data/plugins/autocomplete.lua
@@ -71,10 +71,19 @@ local max_symbols = config.max_symbols
core.add_thread(function()
local cache = setmetatable({}, { __mode = "k" })
+ local function get_syntax_symbols(symbols, doc)
+ if doc.syntax then
+ for sym in pairs(doc.syntax.symbols) do
+ symbols[sym] = true
+ end
+ end
+ end
+
local function get_symbols(doc)
- if doc.disable_symbols then return {} end
- local i = 1
local s = {}
+ get_syntax_symbols(s, doc)
+ if doc.disable_symbols then return s end
+ local i = 1
local symbols_count = 0
while i < #doc.lines do
for sym in doc.lines[i]:gmatch(config.symbol_pattern) do
diff --git a/data/plugins/workspace.lua b/data/plugins/workspace.lua
index 1edfbe1e..73b8486f 100644
--- a/data/plugins/workspace.lua
+++ b/data/plugins/workspace.lua
@@ -107,10 +107,14 @@ local function load_view(t)
dv = DocView(core.open_doc())
if t.text then dv.doc:insert(1, 1, t.text) end
else
- -- we have a filename, try to read the file
- local ok, doc = pcall(core.open_doc, t.filename)
- if ok then
- dv = DocView(doc)
+ -- we have a filename, try to read the file.
+ -- proceed to create a view only if the file exists.
+ local info = system.get_file_info(t.filename)
+ if info and info.type == "file" then
+ local ok, doc = pcall(core.open_doc, t.filename)
+ if ok then
+ dv = DocView(doc)
+ end
end
end
-- doc view "dv" can be nil here if the filename associated to the document
diff --git a/resources/linux/org.lite_xl.lite_xl.appdata.xml b/resources/linux/org.lite_xl.lite_xl.appdata.xml
index c5895178..49c23430 100644
--- a/resources/linux/org.lite_xl.lite_xl.appdata.xml
+++ b/resources/linux/org.lite_xl.lite_xl.appdata.xml
@@ -17,11 +17,11 @@
<screenshots>
<screenshot type="default">
<caption>The editor window</caption>
- <image>https://lite-xl.github.io/assets/img/screenshots/editor.png</image>
+ <image>https://lite-xl.com/assets/img/editor.png</image>
</screenshot>
</screenshots>
- <url type="homepage">https://lite-xl.github.io</url>
+ <url type="homepage">https://lite-xl.com</url>
<provides>
<binary>lite-xl</binary>
diff --git a/scripts/appimage.sh b/scripts/appimage.sh
index 8844fafe..dc28c5e3 100644
--- a/scripts/appimage.sh
+++ b/scripts/appimage.sh
@@ -20,7 +20,7 @@ show_help(){
echo "-n --nobuild Skips the build step, use existing files."
echo "-s --static Specify if building using static libraries"
echo " by using lhelper tool."
- echo "-v --version VERSION Specify a version, non whitespace separated string."
+ echo "-v --version version Specify a version, non whitespace separated string."
echo
}
@@ -31,7 +31,7 @@ STATIC_BUILD=false
for i in "$@"; do
case $i in
- -h|--belp)
+ -h|--help)
show_help
exit 0
;;
@@ -49,7 +49,7 @@ for i in "$@"; do
shift
;;
-v|--version)
- VERSION="$2"
+ version="$2"
shift
shift
;;
@@ -117,6 +117,7 @@ generate_appimage() {
DESTDIR="$(realpath LiteXL.AppDir)" meson install --skip-subprojects -C ${BUILD_DIR}
mv AppRun LiteXL.AppDir/
+ strip LiteXL.AppDir/AppRun
# These could be symlinks but it seems they doesn't work with AppimageLauncher
cp resources/icons/lite-xl.svg LiteXL.AppDir/
cp resources/linux/org.lite_xl.lite_xl.desktop LiteXL.AppDir/
@@ -144,16 +145,16 @@ generate_appimage() {
fi
done
echo " Ignoring: $libname"
- done < <(ldd build/src/lite-xl | awk '{print $1 " " $3}')
+ done < <(ldd ${BUILD_DIR}/src/lite-xl | awk '{print $1 " " $3}')
fi
echo "Generating AppImage..."
- local version=""
- if [ -n "$VERSION" ]; then
- version="-$VERSION"
+ local version_tag=""
+ if [ -n "$version" ]; then
+ version_tag="-$version"
fi
- ./appimagetool LiteXL.AppDir LiteXL${version}-${ARCH}.AppImage
+ ./appimagetool LiteXL.AppDir LiteXL${version_tag}-${ARCH}.AppImage
}
setup_appimagetool
diff --git a/scripts/lite-xl-ubuntu-build.yml b/scripts/lite-xl-ubuntu-build.yml
new file mode 100644
index 00000000..5cd5dce4
--- /dev/null
+++ b/scripts/lite-xl-ubuntu-build.yml
@@ -0,0 +1,26 @@
+image: ubuntu/18.04
+packages:
+ [python3, python3-pip, pkg-config, ninja-build, libx11-dev, libxext-dev, zip, unzip, gcc, g++]
+sources:
+ - https://git.sr.ht/~franko/lite-xl
+shell: true
+tasks:
+ - enable-local: |
+ echo 'export PATH="$HOME/.local/bin:$PATH"' >> "$HOME/.buildenv"
+ - prepare-setup: |
+ pip3 install --user meson
+ - lhelper-install: |
+ git clone https://github.com/franko/lhelper
+ cd lhelper
+ bash install "$HOME/.local"
+ - lhelper-create-env: |
+ lhelper create lite-xl -n
+ source "$(lhelper env-source lite-xl)"
+ lhelper install sdl2
+ lhelper install freetype2
+ lhelper install pcre2
+ - build: |
+ cd lite-xl
+ git checkout master-2.0
+ source "$(lhelper env-source lite-xl)"
+ bash build-packages.sh
diff --git a/scripts/package.sh b/scripts/package.sh
index f6d26d00..64bee032 100644
--- a/scripts/package.sh
+++ b/scripts/package.sh
@@ -91,6 +91,7 @@ main() {
local dest_dir=lite-xl
local prefix=/
local version
+ local version_tag
local addons=false
local appimage=false
local binary=false
@@ -120,7 +121,9 @@ main() {
shift
;;
-v|--version)
- if [[ -n $2 ]]; then version="-$2"; fi
+ # if [[ -n $2 ]]; then version="-$2"; fi
+ version="$2"
+ version_tag="-$version"
shift
shift
;;
@@ -174,7 +177,7 @@ main() {
# The source package doesn't require a previous build,
# nor the following install step, so run it now.
- if [[ $source == true ]]; then source_package "lite-xl$version-src"; fi
+ if [[ $source == true ]]; then source_package "lite-xl${version_tag}-src"; fi
# No packages request
if [[ $appimage == false && $binary == false && $dmg == false && $innosetup == false ]]; then
@@ -190,7 +193,7 @@ main() {
local data_dir="$(pwd)/${dest_dir}/data"
local exe_file="$(pwd)/${dest_dir}/lite-xl"
- local package_name=lite-xl$version-$platform-$arch
+ local package_name=lite-xl${version_tag}-${platform}-${arch}
local bundle=false
local portable=false
local stripcmd="strip"
@@ -252,7 +255,11 @@ main() {
fi
fi
- if [[ $appimage == true ]]; then source scripts/appimage.sh; fi
+ local version_option=()
+ if [[ -n $version ]]; then version_option=("--version" "${version}"); fi
+ if [[ $appimage == true ]]; then
+ bash scripts/appimage.sh -n -b "$build_dir" ${version_option[@]}
+ fi
if [[ $bundle == true && $dmg == true ]]; then source scripts/appdmg.sh "${package_name}"; fi
if [[ $innosetup == true ]]; then source scripts/innosetup/innosetup.sh -b "${build_dir}"; fi
}
diff --git a/scripts/repackage-appimage.sh b/scripts/repackage-appimage.sh
new file mode 100644
index 00000000..b21cdfa0
--- /dev/null
+++ b/scripts/repackage-appimage.sh
@@ -0,0 +1,73 @@
+#!/bin/env bash
+set -e
+
+wget="wget --retry-connrefused --waitretry=1 --read-timeout=20 --no-check-certificate"
+
+workdir=".repackage"
+rm -fr "$workdir" && mkdir "$workdir" && pushd "$workdir"
+
+ARCH="x86_64"
+
+create_appimage() {
+ rm -fr LiteXL.AppDir
+
+ echo "Creating LiteXL.AppDir..."
+
+ mkdir -p LiteXL.AppDir/usr
+ tar xf "$1" -C LiteXL.AppDir/usr --strip-components=1
+ cp AppRun LiteXL.AppDir/
+ pushd LiteXL.AppDir
+ strip AppRun
+ mv usr/share/applications/org.lite_xl.lite_xl.desktop .
+ mv usr/share/icons/hicolor/scalable/apps/lite-xl.svg .
+ rm -fr usr/share/{icons,applications,metainfo}
+ popd
+
+ echo "Generating AppImage..."
+ local appimage_name="${1/lite-xl/LiteXL}"
+ appimage_name="${appimage_name/-linux/}"
+ appimage_name="${appimage_name/%.tar.gz/.AppImage}"
+
+ ./appimagetool LiteXL.AppDir "$appimage_name"
+}
+
+repackage_from_github () {
+ assets=($($wget -q -nv -O- https://api.github.com/repos/franko/lite-xl/releases/latest | grep "browser_download_url" | cut -d '"' -f 4))
+
+ for url in "${assets[@]}"; do
+ if [[ $url == *"linux-x86_64"* ]]; then
+ echo "getting: $url"
+ $wget -q "$url" || exit 1
+ create_appimage "${url##*/}"
+ fi
+ done
+}
+
+setup_appimagetool() {
+ if ! which appimagetool > /dev/null ; then
+ if [ ! -e appimagetool ]; then
+ if ! wget -O appimagetool "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-${ARCH}.AppImage" ; then
+ echo "Could not download the appimagetool for the arch '${ARCH}'."
+ exit 1
+ else
+ chmod 0755 appimagetool
+ fi
+ fi
+ fi
+}
+
+download_appimage_apprun() {
+ if [ ! -e AppRun ]; then
+ if ! wget -O AppRun "https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-${ARCH}" ; then
+ echo "Could not download AppRun for the arch '${ARCH}'."
+ exit 1
+ else
+ chmod 0755 AppRun
+ fi
+ fi
+}
+
+setup_appimagetool
+download_appimage_apprun
+repackage_from_github
+