Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package lite-xl-widgets for openSUSE:Factory checked in at 2022-11-04 17:38:20 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/lite-xl-widgets (Old) and /work/SRC/openSUSE:Factory/.lite-xl-widgets.new.2275 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "lite-xl-widgets" Fri Nov 4 17:38:20 2022 rev:2 rq:1033566 version:git20221023.648c067 Changes: -------- --- /work/SRC/openSUSE:Factory/lite-xl-widgets/lite-xl-widgets.changes 2022-10-19 13:18:05.909274514 +0200 +++ /work/SRC/openSUSE:Factory/.lite-xl-widgets.new.2275/lite-xl-widgets.changes 2022-11-04 17:42:09.183063477 +0100 @@ -1,0 +2,11 @@ +Thu Nov 03 18:14:55 UTC 2022 - scott.bradn...@suse.com + +- Update to version git20221023.648c067: + * textbox: fix get_gutter_width returning nil, fixes lite-xl/lite-xl#1158 + * fontslist: allow new max of 10 fonts + * use new on_scale_change logic from lite-xl master + * fontslist: limit maximum fonts to 3 + * textbox: add double and triple click selection + * Adaptation to newer scroll API + +------------------------------------------------------------------- Old: ---- lite-xl-widgets-git20220917.6d8c23d.tar.gz New: ---- lite-xl-widgets-git20221023.648c067.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ lite-xl-widgets.spec ++++++ --- /var/tmp/diff_new_pack.yKps1o/_old 2022-11-04 17:42:09.767066528 +0100 +++ /var/tmp/diff_new_pack.yKps1o/_new 2022-11-04 17:42:09.775066570 +0100 @@ -17,12 +17,13 @@ %define programname lite-xl Name: lite-xl-widgets -Version: git20220917.6d8c23d +Version: git20221023.648c067 Release: 0 Summary: Widgets for %{programname} License: MIT URL: https://github.com/lite-xl/lite-xl-widgets Source0: %{name}-%{version}.tar.gz +Requires: lite-xl BuildArch: noarch %description ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.yKps1o/_old 2022-11-04 17:42:09.823066820 +0100 +++ /var/tmp/diff_new_pack.yKps1o/_new 2022-11-04 17:42:09.823066820 +0100 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/lite-xl/lite-xl-widgets</param> - <param name="changesrevision">6d8c23d550d75a01251eafc7296e03b081805c2f</param></service></servicedata> + <param name="changesrevision">648c06723180c90194cba39c51e21bc05a707b2b</param></service></servicedata> (No newline at EOF) ++++++ lite-xl-widgets-git20220917.6d8c23d.tar.gz -> lite-xl-widgets-git20221023.648c067.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-widgets-git20220917.6d8c23d/button.lua new/lite-xl-widgets-git20221023.648c067/button.lua --- old/lite-xl-widgets-git20220917.6d8c23d/button.lua 2022-09-18 03:54:40.000000000 +0200 +++ new/lite-xl-widgets-git20221023.648c067/button.lua 2022-10-23 06:34:26.000000000 +0200 @@ -25,6 +25,8 @@ function Button:new(parent, label) Button.super.new(self, parent) + self.type_name = "widget.button" + self.icon = { code = nil, color = nil, hover_color = nil } @@ -103,7 +105,8 @@ self.hover_back = nil end -function Button:on_rescale(new_scale, prev_scale) +function Button:on_scale_change(new_scale, prev_scale) + Button.super.on_scale_change(self, new_scale, prev_scale) self.padding.x = self.padding.x * (new_scale / prev_scale) self.padding.y = self.padding.y * (new_scale / prev_scale) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-widgets-git20220917.6d8c23d/checkbox.lua new/lite-xl-widgets-git20221023.648c067/checkbox.lua --- old/lite-xl-widgets-git20220917.6d8c23d/checkbox.lua 2022-09-18 03:54:40.000000000 +0200 +++ new/lite-xl-widgets-git20221023.648c067/checkbox.lua 2022-10-23 06:34:26.000000000 +0200 @@ -16,6 +16,7 @@ ---@param label string function CheckBox:new(parent, label) CheckBox.super.new(self, parent) + self.type_name = "widget.checkbox" self.checked = false self:set_label(label or "") end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-widgets-git20220917.6d8c23d/dialog.lua new/lite-xl-widgets-git20221023.648c067/dialog.lua --- old/lite-xl-widgets-git20220917.6d8c23d/dialog.lua 2022-09-18 03:54:40.000000000 +0200 +++ new/lite-xl-widgets-git20221023.648c067/dialog.lua 2022-10-23 06:34:26.000000000 +0200 @@ -21,6 +21,8 @@ function Dialog:new(title) Dialog.super.new(self) + self.type_name = "widget.dialog" + self.draggable = true self.scrollable = false diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-widgets-git20220917.6d8c23d/filepicker.lua new/lite-xl-widgets-git20221023.648c067/filepicker.lua --- old/lite-xl-widgets-git20220917.6d8c23d/filepicker.lua 2022-09-18 03:54:40.000000000 +0200 +++ new/lite-xl-widgets-git20221023.648c067/filepicker.lua 2022-10-23 06:34:26.000000000 +0200 @@ -67,6 +67,8 @@ local this = self + self.type_name = "widget.filepicker" + self.filters = {} self.border.width = 0 self.pick_mode = FilePicker.mode.FILE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-widgets-git20220917.6d8c23d/foldingbook.lua new/lite-xl-widgets-git20221023.648c067/foldingbook.lua --- old/lite-xl-widgets-git20220917.6d8c23d/foldingbook.lua 2022-09-18 03:54:40.000000000 +0200 +++ new/lite-xl-widgets-git20221023.648c067/foldingbook.lua 2022-10-23 06:34:26.000000000 +0200 @@ -24,6 +24,7 @@ ---@param parent widget function FoldingBook:new(parent) FoldingBook.super.new(self, parent) + self.type_name = "widget.foldingbook" self.panes = {} self.scrollable = true end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-widgets-git20220917.6d8c23d/fontdialog.lua new/lite-xl-widgets-git20221023.648c067/fontdialog.lua --- old/lite-xl-widgets-git20220917.6d8c23d/fontdialog.lua 2022-09-18 03:54:40.000000000 +0200 +++ new/lite-xl-widgets-git20221023.648c067/fontdialog.lua 2022-10-23 06:34:26.000000000 +0200 @@ -45,6 +45,8 @@ local this = self + self.type_name = "widget.fontdialog" + self.preview = Label(self.panel, "No Font Selected") self.preview.border.width = 1 self.preview.clickable = true diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-widgets-git20220917.6d8c23d/fontslist.lua new/lite-xl-widgets-git20221023.648c067/fontslist.lua --- old/lite-xl-widgets-git20220917.6d8c23d/fontslist.lua 2022-09-18 03:54:40.000000000 +0200 +++ new/lite-xl-widgets-git20221023.648c067/fontslist.lua 2022-10-23 06:34:26.000000000 +0200 @@ -29,6 +29,8 @@ function FontsList:new(parent) FontsList.super.new(self, parent) + self.type_name = "widget.fontslist" + self.border.width = 0 self.dialog = false @@ -68,6 +70,10 @@ self.add = Button(self, "Add") self.add:set_icon("B") function self.add:on_click() + if #this.list.rows > 9 then + MessageBox.error("Max Fonts Reached", "Only a maximum of ten fonts can be added.") + return + end if not this.dialog then this.dialog = true ---@type widget.inputdialog diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-widgets-git20220917.6d8c23d/init.lua new/lite-xl-widgets-git20221023.648c067/init.lua --- old/lite-xl-widgets-git20220917.6d8c23d/init.lua 2022-09-18 03:54:40.000000000 +0200 +++ new/lite-xl-widgets-git20221023.648c067/init.lua 2022-10-23 06:34:26.000000000 +0200 @@ -7,6 +7,7 @@ local core = require "core" local config = require "core.config" local style = require "core.style" +local keymap = require "core.keymap" local View = require "core.view" local RootView = require "core.rootview" @@ -58,6 +59,7 @@ ---@field public foreground_color renderer.color ---@field public background_color renderer.color ---@field public render_background boolean +---@field public type_name string ---@field private visible boolean ---@field private has_focus boolean ---@field private dragged boolean @@ -71,7 +73,7 @@ ---@field private mouse_is_pressed boolean ---@field private mouse_is_hovering boolean ---@field private mouse_pressed_outside boolean ----@field private was_scrolling boolean +---@field private is_scrolling boolean local Widget = View:extend() ---Indicates on a widget.styledtext that a new line follows. @@ -93,6 +95,7 @@ function Widget:new(parent, floating) Widget.super.new(self) + self.type_name = "widget" self.parent = parent self.name = "---" -- defaults to the application name if type(floating) == "boolean" then @@ -123,7 +126,7 @@ self.textview = nil self.mouse = {x = 0, y = 0} self.prev_size = {x = 0, y = 0} - self.was_scrolling = false + self.is_scrolling = false self.mouse_is_pressed = false self.mouse_is_hovering = false @@ -131,8 +134,6 @@ -- used to allow proper node resizing self.mouse_pressed_outside = false - self.current_scale = SCALE - if parent then parent:add_child(self) elseif self.defer_draw then @@ -143,6 +144,11 @@ self:set_position(0, 0) end +---Useful for debugging. +function Widget:__tostring() + return self.type_name +end + ---Add a child widget, automatically assign a zindex if non set and sorts ---them in reverse order for better events matching. ---@param child widget @@ -590,12 +596,12 @@ function Widget:centered() local w, h = system.get_window_size(); if self.parent then - w = self.parent.size.x - (self.parent.border.width*2) - h = self.parent.size.y - (self.parent.border.width*2) + w = self.parent:get_width() + h = self.parent:get_height() end self:set_position( - (w / 2) - (self.size.x / 2), - (h / 2) - (self.size.y / 2) + (w / 2) - (self:get_width() / 2), + (h / 2) - (self:get_height() / 2) ) end @@ -634,13 +640,20 @@ end end ----Calculates the scrollable size taking into account the bottom most +---Calculates the y scrollable size taking into account the bottom most ---widget or the size of the widget it self if greater. ---@return number function Widget:get_scrollable_size() return math.max(self.size.y, self:get_real_height()) end +---Calculates the x scrollable size taking into account the right most +---widget or the size of the widget it self if greater. +---@return number +function Widget:get_h_scrollable_size() + return math.max(self.size.x, self:get_real_width()) +end + ---The name that is displayed on lite-xl tabs. function Widget:get_name() return self.name @@ -692,6 +705,18 @@ function Widget:on_mouse_pressed(button, x, y, clicks) if not self.visible then return false end + if Widget.super.on_mouse_pressed(self, button, x, y, clicks) then + local parent = self.parent + while parent do + -- propagate to parents so if mouse is not on top still + -- reach the childrens when the mouse is released + parent.is_scrolling = true + parent = parent.parent + end + self.is_scrolling = true + return true + end + for _, child in pairs(self.childs) do if child:mouse_on_top(x, y) and child.clickable then child:on_mouse_pressed(button, x, y, clicks) @@ -700,18 +725,6 @@ end if self:mouse_on_top(x, y) then - Widget.super.on_mouse_pressed(self, button, x, y, clicks) - - if self.hovered_scrollbar then - if self.parent then - -- propagate to parents so if mouse is not on top still - -- reach the childrens when the mouse is released - self.parent.was_scrolling = true - end - self.was_scrolling = true - return true - end - self.mouse_is_pressed = true if self.parent then @@ -742,21 +755,37 @@ function Widget:on_mouse_released(button, x, y) if not self.visible then return false end + Widget.super.on_mouse_released(self, button, x, y) + + if self.is_scrolling then + self.is_scrolling = false + local parent = self.parent + while parent do + parent.is_scrolling = false + parent = parent.parent + end + for _, child in pairs(self.childs) do + if child.is_scrolling then + child:on_mouse_released(button, x, y) + end + end + return true + end + self:swap_active_child() + if self.child_active then + self.child_active:on_mouse_released(button, x, y) + end + if not self.dragged then for _, child in pairs(self.childs) do local mouse_on_top = child:mouse_on_top(x, y) if mouse_on_top or - child.was_scrolling - or child.mouse_is_pressed then - -- if child ~= self.child_active then - -- self:swap_active_child() - -- end child:on_mouse_released(button, x, y) if child.input_text then self:swap_active_child(child) @@ -769,28 +798,14 @@ end end - if self.was_scrolling then - Widget.super.on_mouse_released(self, button, x, y) - self.mouse_is_pressed = false - self.was_scrolling = false - if self.parent then - self.parent.was_scrolling = false - end - return false - end - if - not self:mouse_on_top(x, y) + not self.dragged and not self.mouse_is_pressed - and - not self.was_scrolling then return false end - Widget.super.on_mouse_released(self, button, x, y) - if self.mouse_is_pressed then if self:mouse_on_top(x, y) then self:on_click(button, x, y) @@ -839,17 +854,35 @@ function Widget:on_mouse_moved(x, y, dx, dy) if not self.visible then return false end + Widget.super.on_mouse_moved(self, x, y, dx, dy) + + if self.is_scrolling then + if not self:scrollbar_dragging() then + for _, child in pairs(self.childs) do + if child.is_scrolling then + child:on_mouse_moved(x, y, dx, dy) + break + end + end + end + return true + end + -- store latest mouse coordinates for usage on the on_mouse_wheel event. self.mouse.x = x self.mouse.y = y + if self.child_active then + self.child_active:on_mouse_moved(x, y, dx, dy) + end + if not self.dragged then local hovered = nil for _, child in pairs(self.childs) do if not hovered and - (child:mouse_on_top(x, y) or child.was_scrolling or child.mouse_is_pressed) + (child:mouse_on_top(x, y) or child.mouse_is_pressed) then hovered = child elseif child.mouse_is_hovering then @@ -874,20 +907,12 @@ end if - self:mouse_on_top(x, y) - or - self.was_scrolling - or - self.mouse_is_pressed - or - not self.parent + not self:mouse_on_top(x, y) + and + not self.mouse_is_pressed + and + not self.mouse_is_hovering then - Widget.super.on_mouse_moved(self, x, y, dx, dy) - if self.dragging_scrollbar then - self.dragged = true - return true - end - else return false end @@ -938,7 +963,7 @@ end end -function Widget:on_mouse_wheel(y) +function Widget:on_mouse_wheel(y, x) if not self.visible or @@ -949,14 +974,23 @@ for _, child in pairs(self.childs) do if child:mouse_on_top(self.mouse.x, self.mouse.y) then - if child:on_mouse_wheel(y) then + if child:on_mouse_wheel(y, x) then return true end end end if self.scrollable then - self.scroll.to.y = self.scroll.to.y + y * -config.mouse_wheel_scroll + if keymap.modkeys["shift"] then + x = y + y = 0 + end + if y and y ~= 0 then + self.scroll.to.y = self.scroll.to.y + y * -config.mouse_wheel_scroll + end + if x and x ~= 0 then + self.scroll.to.x = self.scroll.to.x + x * -config.mouse_wheel_scroll + end return true end @@ -967,30 +1001,24 @@ ---any neccesary changes in sizes, padding, etc... ---@param new_scale number ---@param prev_scale number -function Widget:on_rescale(new_scale, prev_scale) end +function Widget:on_scale_change(new_scale, prev_scale) + local font_type = type(self.font) + if + font_type == "userdata" + or + (font_type == "table" and not self.font.container) + then + self.font:set_size( + self.font:get_size() * (new_scale / prev_scale) + ) + end +end ---If visible execute the widget calculations and returns true. ---@return boolean function Widget:update() if not self:is_visible() then return false end - if self.current_scale ~= SCALE then - local font_type = type(self.font) - if - font_type == "userdata" - or - (font_type == "table" and not self.font.container) - then - self.font:set_size( - self.font:get_size() * (SCALE / self.current_scale) - ) - end - for _, child in pairs(self.childs) do - child:on_rescale(SCALE, self.current_scale) - end - self.current_scale = SCALE - end - Widget.super.update(self) -- call this to be able to properly scroll @@ -1007,12 +1035,6 @@ if self.scrollable then Widget.super.draw_scrollbar(self) end - - for i=#self.childs, 1, -1 do - if self.childs[i].visible and self.childs[i].scrollable then - self.childs[i]:draw_scrollbar() - end - end end ---If visible draw the widget and returns true. @@ -1058,11 +1080,9 @@ ---Recursively destroy all childs from the widget. function Widget:destroy_childs() - ::remove_child:: - for idx, child in ipairs(self.childs) do - child:destroy_childs() - table.remove(self.childs, idx) - goto remove_child + for _=1, #self.childs do + self.childs[1]:destroy_childs() + table.remove(self.childs, 1) end end @@ -1157,7 +1177,13 @@ or (moved or not widget:on_mouse_moved(x, y, dx, dy)) then - if not widget.child_active and widget.outside_view then + if + not widget.is_scrolling + and + not widget.child_active + and + widget.outside_view + then core.set_active_view(widget.outside_view) widget.outside_view = nil end @@ -1177,14 +1203,14 @@ end end - function RootView:on_mouse_wheel(y) + function RootView:on_mouse_wheel(y, x) for i=#floating_widgets, 1, -1 do local widget = floating_widgets[i] - if widget.defer_draw and widget:on_mouse_wheel(y) then + if widget.defer_draw and widget:on_mouse_wheel(y, x) then return true end end - return root_view_on_mouse_wheel(self, y) + return root_view_on_mouse_wheel(self, y, x) end function RootView:on_file_dropped(filename, x, y) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-widgets-git20220917.6d8c23d/inputdialog.lua new/lite-xl-widgets-git20221023.648c067/inputdialog.lua --- old/lite-xl-widgets-git20220917.6d8c23d/inputdialog.lua 2022-09-18 03:54:40.000000000 +0200 +++ new/lite-xl-widgets-git20221023.648c067/inputdialog.lua 2022-10-23 06:34:26.000000000 +0200 @@ -24,6 +24,8 @@ function InputDialog:new(title, message, text) InputDialog.super.new(self, title or "Enter Value") + self.type_name = "widget.inputdialog" + self.message = Label(self.panel, message) self.text = TextBox(self.panel, text or "") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-widgets-git20220917.6d8c23d/itemslist.lua new/lite-xl-widgets-git20221023.648c067/itemslist.lua --- old/lite-xl-widgets-git20220917.6d8c23d/itemslist.lua 2022-09-18 03:54:40.000000000 +0200 +++ new/lite-xl-widgets-git20221023.648c067/itemslist.lua 2022-10-23 06:34:26.000000000 +0200 @@ -21,6 +21,8 @@ function ItemsList:new(parent) ItemsList.super.new(self, parent) + self.type_name = "widget.itemslist" + self.border.width = 0 self.dialog = false diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-widgets-git20220917.6d8c23d/keybinddialog.lua new/lite-xl-widgets-git20221023.648c067/keybinddialog.lua --- old/lite-xl-widgets-git20220917.6d8c23d/keybinddialog.lua 2022-09-18 03:54:40.000000000 +0200 +++ new/lite-xl-widgets-git20221023.648c067/keybinddialog.lua 2022-10-23 06:34:26.000000000 +0200 @@ -34,6 +34,8 @@ function KeybindDialog:new() KeybindDialog.super.new(self, "Keybinding Selector") + self.type_name = "widget.keybinddialog" + self.selected = nil local this = self diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-widgets-git20220917.6d8c23d/label.lua new/lite-xl-widgets-git20221023.648c067/label.lua --- old/lite-xl-widgets-git20220917.6d8c23d/label.lua 2022-09-18 03:54:40.000000000 +0200 +++ new/lite-xl-widgets-git20221023.648c067/label.lua 2022-10-23 06:34:26.000000000 +0200 @@ -15,6 +15,7 @@ ---@param label string function Label:new(parent, label) Label.super.new(self, parent) + self.type_name = "widget.label" self.clickable = false self.border.width = 0 self.custom_size = {x = 0, y = 0} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-widgets-git20220917.6d8c23d/line.lua new/lite-xl-widgets-git20221023.648c067/line.lua --- old/lite-xl-widgets-git20220917.6d8c23d/line.lua 2022-09-18 03:54:40.000000000 +0200 +++ new/lite-xl-widgets-git20221023.648c067/line.lua 2022-10-23 06:34:26.000000000 +0200 @@ -18,6 +18,7 @@ ---@param padding number function Line:new(parent, thickness, padding) Line.super.new(self, parent) + self.type_name = "widget.line" self.size.y = thickness or 2 self.custom_width = nil self.border.width = 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-widgets-git20220917.6d8c23d/listbox.lua new/lite-xl-widgets-git20221023.648c067/listbox.lua --- old/lite-xl-widgets-git20220917.6d8c23d/listbox.lua 2022-09-18 03:54:40.000000000 +0200 +++ new/lite-xl-widgets-git20221023.648c067/listbox.lua 2022-10-23 06:34:26.000000000 +0200 @@ -51,6 +51,7 @@ ---@param parent widget function ListBox:new(parent) ListBox.super.new(self, parent) + self.type_name = "widget.listbox" self.scrollable = true self.rows = {} self.row_data = {} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-widgets-git20220917.6d8c23d/messagebox.lua new/lite-xl-widgets-git20221023.648c067/messagebox.lua --- old/lite-xl-widgets-git20220917.6d8c23d/messagebox.lua 2022-09-18 03:54:40.000000000 +0200 +++ new/lite-xl-widgets-git20221023.648c067/messagebox.lua 2022-10-23 06:34:26.000000000 +0200 @@ -50,6 +50,7 @@ ---@param icon_color renderer.color function MessageBox:new(parent, title, message, icon, icon_color) MessageBox.super.new(self, parent) + self.type_name = "widget.messagebox" self.draggable = true self.scrollable = true self.title = Label(self, "") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-widgets-git20220917.6d8c23d/notebook.lua new/lite-xl-widgets-git20221023.648c067/notebook.lua --- old/lite-xl-widgets-git20220917.6d8c23d/notebook.lua 2022-09-18 03:54:40.000000000 +0200 +++ new/lite-xl-widgets-git20221023.648c067/notebook.lua 2022-10-23 06:34:26.000000000 +0200 @@ -27,6 +27,7 @@ ---@param parent widget function NoteBook:new(parent) NoteBook.super.new(self, parent) + self.type_name = "widget.notebook" self.panes = {} self.active_pane = nil end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-widgets-git20220917.6d8c23d/numberbox.lua new/lite-xl-widgets-git20221023.648c067/numberbox.lua --- old/lite-xl-widgets-git20220917.6d8c23d/numberbox.lua 2022-09-18 03:54:40.000000000 +0200 +++ new/lite-xl-widgets-git20221023.648c067/numberbox.lua 2022-10-23 06:34:26.000000000 +0200 @@ -27,6 +27,8 @@ function NumberBox:new(parent, value, min, max, step) NumberBox.super.new(self, parent) + self.type_name = "widget.numberbox" + self.scrollable = true self:set_range(min, max) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-widgets-git20220917.6d8c23d/progressbar.lua new/lite-xl-widgets-git20221023.648c067/progressbar.lua --- old/lite-xl-widgets-git20220917.6d8c23d/progressbar.lua 2022-09-18 03:54:40.000000000 +0200 +++ new/lite-xl-widgets-git20221023.648c067/progressbar.lua 2022-10-23 06:34:26.000000000 +0200 @@ -21,6 +21,7 @@ ---@param width number function ProgressBar:new(parent, percent, width) ProgressBar.super.new(self, parent) + self.type_name = "widget.progressbar" self.clickable = false self.percent = percent or 0 self.percent_width = 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-widgets-git20220917.6d8c23d/selectbox.lua new/lite-xl-widgets-git20221023.648c067/selectbox.lua --- old/lite-xl-widgets-git20220917.6d8c23d/selectbox.lua 2022-09-18 03:54:40.000000000 +0200 +++ new/lite-xl-widgets-git20221023.648c067/selectbox.lua 2022-10-23 06:34:26.000000000 +0200 @@ -21,6 +21,7 @@ ---@param label string function SelectBox:new(parent, label) SelectBox.super.new(self, parent) + self.type_name = "widget.selectbox" self.size.x = 200 + (style.padding.x * 2) self.size.y = self:get_font():get_height() + (style.padding.y * 2) self.list_container = Widget() @@ -28,7 +29,6 @@ self.size.x - self.list_container.border.width, 150 ) - self.list_container.border.color = style.caret self.list = ListBox(self.list_container) self.list.border.width = 0 self.list:enable_expand(true) @@ -75,7 +75,7 @@ ---@param text string ---@param max_width number ---@param font widget.font Default is style.font ----@param overflow_chars string Default is '...' +---@param overflow_chars? string Default is '...' ---@return string chopped_text ---@return boolean overflows True if the text overflows function SelectBox:text_overflow(text, max_width, font, overflow_chars) @@ -146,7 +146,7 @@ local y1 = self.position.y + self:get_height() local y2 = self.position.y - self.list:get_height() - local w, h = system.get_window_size() + local _, h = system.get_window_size() if y1 + self.list:get_height() <= h then self.list_container:set_position( @@ -194,6 +194,8 @@ if button == "left" then self:reposition_container() + self.list_container.border.color = style.caret + self.list_container:toggle_visible() self.list:resize_to_parent() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-widgets-git20220917.6d8c23d/textbox.lua new/lite-xl-widgets-git20221023.648c067/textbox.lua --- old/lite-xl-widgets-git20220917.6d8c23d/textbox.lua 2022-09-18 03:54:40.000000000 +0200 +++ new/lite-xl-widgets-git20221023.648c067/textbox.lua 2022-10-23 06:34:26.000000000 +0200 @@ -3,8 +3,8 @@ -- local core = require "core" -local command = require "core.command" local style = require "core.style" +local translate = require "core.doc.translate" local Doc = require "core.doc" local DocView = require "core.docview" local View = require "core.view" @@ -44,10 +44,6 @@ return 0 end -function TextView:scroll_to_make_visible() - -- no-op function to disable this functionality -end - function TextView:get_text() return self.doc:get_text(1, 1, 1, math.huge) end @@ -61,7 +57,7 @@ end function TextView:get_gutter_width() - return self.gutter_width + return self.gutter_width or 0 end function TextView:get_line_height() @@ -89,13 +85,11 @@ local lh = self:get_line_height() local x, y = self:get_line_screen_position(minline) - local gw, gpad = self:get_gutter_width() for i = minline, maxline do - self:draw_line_gutter(i, self.position.x, y, gpad and gw - gpad or gw) + self:draw_line_gutter(i, self.position.x, y) y = y + lh end - local pos = self.position x, y = self:get_line_screen_position(minline) for i = minline, maxline do self:draw_line_body(i, x, y) @@ -114,6 +108,7 @@ function TextBox:new(parent, text, placeholder) TextBox.super.new(self, parent) + self.type_name = "widget.textbox" self.textview = TextView() self.textview.name = parent.name self.size.x = 200 + (style.padding.x * 2) @@ -125,6 +120,7 @@ self.input_text = true self.cursor = "ibeam" self.active = false + self.drag_select = false if text ~= "" then self.textview:set_text(text, select) @@ -135,7 +131,7 @@ local this = self - function self.textview.doc:on_text_change(type) + function self.textview.doc:on_text_change() this:on_change(this:get_text()) end @@ -154,8 +150,7 @@ end ---@param width integer ----@param height? integer Ignored on the textbox -function TextBox:set_size(width, height) +function TextBox:set_size(width) TextBox.super.set_size( self, width, @@ -188,7 +183,16 @@ function TextBox:on_mouse_pressed(button, x, y, clicks) if TextBox.super.on_mouse_pressed(self, button, x, y, clicks) then self.textview:on_mouse_pressed(button, x, y, clicks) - command.perform("doc:set-cursor", x, y) + local line, col = self.textview:resolve_screen_position(x, y) + self.drag_select = { line = line, col = col } + self.textview.doc:set_selection(line, col, line, col) + if clicks == 2 then + local line1, col1 = translate.start_of_word(self.textview.doc, line, col) + local line2, col2 = translate.end_of_word(self.textview.doc, line1, col1) + self.textview.doc:set_selection(line2, col2, line1, col1) + elseif clicks == 3 then + self.textview.doc:set_selection(1, 1, 1, math.huge) + end if core.active_view ~= self.textview then self.textview:on_mouse_released(button, x, y) end @@ -199,6 +203,7 @@ function TextBox:on_mouse_released(button, x, y) if TextBox.super.on_mouse_released(self, button, x, y) then + self.drag_select = false self.textview:on_mouse_released(button, x, y) return true end @@ -206,10 +211,15 @@ end function TextBox:on_mouse_moved(x, y, dx, dy) + if self.drag_select then + local line, col = self.textview:resolve_screen_position(x, y) + self.textview.doc:set_selection( + self.drag_select.line, self.drag_select.col, line, col + ) + end if TextBox.super.on_mouse_moved(self, x, y, dx, dy) then if self.active or core.active_view == self.textview then self.textview:on_mouse_moved(x, y, dx, dy) - system.set_cursor("ibeam") end return true end @@ -223,17 +233,18 @@ self.placeholder_active = false end self.active = true - system.set_cursor("ibeam") + core.request_cursor("ibeam") end function TextBox:deactivate() self.hover_border = nil + self.drag_select = false if self:get_text() == "" then self:set_text(self.placeholder) self.placeholder_active = true end self.active = false - system.set_cursor("arrow") + core.request_cursor("arrow") end function TextBox:on_text_input(text) @@ -253,6 +264,14 @@ function TextBox:update() if not TextBox.super.update(self) then return false end + if + self.drag_select + or + (self.active and self:mouse_on_top(self.mouse.x, self.mouse.y)) + then + core.request_cursor("ibeam") + end + self.textview:update() self.size.y = self:get_font():get_height() + (style.padding.y * 2) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lite-xl-widgets-git20220917.6d8c23d/toggle.lua new/lite-xl-widgets-git20221023.648c067/toggle.lua --- old/lite-xl-widgets-git20220917.6d8c23d/toggle.lua 2022-09-18 03:54:40.000000000 +0200 +++ new/lite-xl-widgets-git20221023.648c067/toggle.lua 2022-10-23 06:34:26.000000000 +0200 @@ -28,6 +28,8 @@ function Toggle:new(parent, label, enable) Toggle.super.new(self, parent) + self.type_name = "widget.toggle" + self.enabled = enable or false self.label = label or "" ++++++ lite-xl-widgets.obsinfo ++++++ --- /var/tmp/diff_new_pack.yKps1o/_old 2022-11-04 17:42:09.915067301 +0100 +++ /var/tmp/diff_new_pack.yKps1o/_new 2022-11-04 17:42:09.919067322 +0100 @@ -1,5 +1,5 @@ name: lite-xl-widgets -version: git20220917.6d8c23d -mtime: 1663466080 -commit: 6d8c23d550d75a01251eafc7296e03b081805c2f +version: git20221023.648c067 +mtime: 1666499666 +commit: 648c06723180c90194cba39c51e21bc05a707b2b