mirror of https://github.com/kepler155c/opus
mouse triple click + textEntry scroll ind
This commit is contained in:
parent
cd6ef0da50
commit
775871c548
|
@ -366,6 +366,7 @@ local mappings = {
|
||||||
-- [ 'control-y' ] = Entry.paste, -- well this won't work...
|
-- [ 'control-y' ] = Entry.paste, -- well this won't work...
|
||||||
|
|
||||||
[ 'mouse_doubleclick' ] = Entry.markWord,
|
[ 'mouse_doubleclick' ] = Entry.markWord,
|
||||||
|
[ 'mouse_tripleclick' ] = Entry.markAll,
|
||||||
[ 'shift-left' ] = Entry.markLeft,
|
[ 'shift-left' ] = Entry.markLeft,
|
||||||
[ 'shift-right' ] = Entry.markRight,
|
[ 'shift-right' ] = Entry.markRight,
|
||||||
[ 'mouse_down' ] = Entry.markAnchor,
|
[ 'mouse_down' ] = Entry.markAnchor,
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
-- not very fuzzy anymore
|
-- not very fuzzy anymore
|
||||||
|
|
||||||
local SCORE_WEIGHT = 1000
|
local SCORE_WEIGHT = 1000
|
||||||
local LEADING_LETTER_PENALTY = -3
|
local LEADING_LETTER_PENALTY = -30
|
||||||
local LEADING_LETTER_PENALTY_MAX = -9
|
local LEADING_LETTER_PENALTY_MAX = -90
|
||||||
|
|
||||||
local _find = string.find
|
local _find = string.find
|
||||||
local _max = math.max
|
local _max = math.max
|
||||||
|
@ -14,6 +14,8 @@ return function(str, pattern)
|
||||||
local start = _find(str, pattern, 1, true)
|
local start = _find(str, pattern, 1, true)
|
||||||
if start then
|
if start then
|
||||||
-- All letters before the current one are considered leading, so add them to our penalty
|
-- All letters before the current one are considered leading, so add them to our penalty
|
||||||
return SCORE_WEIGHT + _max(LEADING_LETTER_PENALTY * (start - 1), LEADING_LETTER_PENALTY_MAX)
|
return SCORE_WEIGHT
|
||||||
|
+ _max(LEADING_LETTER_PENALTY * (start - 1), LEADING_LETTER_PENALTY_MAX)
|
||||||
|
- (#str - #pattern)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -146,18 +146,26 @@ function input:translate(event, code, p1, p2)
|
||||||
p1 == self.x and p2 == self.y and
|
p1 == self.x and p2 == self.y and
|
||||||
(clock - self.timer < .5) then
|
(clock - self.timer < .5) then
|
||||||
|
|
||||||
self.mch = 'mouse_doubleclick'
|
self.clickCount = self.clickCount + 1
|
||||||
self.timer = nil
|
if self.clickCount == 3 then
|
||||||
|
self.mch = 'mouse_tripleclick'
|
||||||
|
self.timer = nil
|
||||||
|
self.clickCount = 1
|
||||||
|
else
|
||||||
|
self.mch = 'mouse_doubleclick'
|
||||||
|
end
|
||||||
else
|
else
|
||||||
self.timer = os.clock()
|
self.timer = os.clock()
|
||||||
self.x = p1
|
self.x = p1
|
||||||
self.y = p2
|
self.y = p2
|
||||||
|
self.clickCount = 1
|
||||||
end
|
end
|
||||||
self.mfired = input:toCode(self.mch, 255)
|
self.mfired = input:toCode(self.mch, 255)
|
||||||
else
|
else
|
||||||
self.mch = 'mouse_up'
|
self.mch = 'mouse_up'
|
||||||
self.mfired = input:toCode(self.mch, 255)
|
self.mfired = input:toCode(self.mch, 255)
|
||||||
end
|
end
|
||||||
|
_syslog(self.mfired)
|
||||||
return {
|
return {
|
||||||
code = self.mfired,
|
code = self.mfired,
|
||||||
button = code,
|
button = code,
|
||||||
|
|
|
@ -465,6 +465,9 @@ function UI.Window:init(args)
|
||||||
until not m
|
until not m
|
||||||
end
|
end
|
||||||
|
|
||||||
|
UI.Window.docs.postInit = [[postInit(VOID)
|
||||||
|
Called once the window has all the properties set.
|
||||||
|
Override to calculate properties or to dynamically add children]]
|
||||||
function UI.Window:postInit()
|
function UI.Window:postInit()
|
||||||
if self.parent then
|
if self.parent then
|
||||||
-- this will cascade down the whole tree of elements starting at the
|
-- this will cascade down the whole tree of elements starting at the
|
||||||
|
@ -604,6 +607,8 @@ function UI.Window:reposition(x, y, w, h)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
UI.Window.docs.raise = [[raise(VOID)
|
||||||
|
Raise this window to the top]]
|
||||||
function UI.Window:raise()
|
function UI.Window:raise()
|
||||||
Array.removeByValue(self.parent.children, self)
|
Array.removeByValue(self.parent.children, self)
|
||||||
table.insert(self.parent.children, self)
|
table.insert(self.parent.children, self)
|
||||||
|
@ -905,7 +910,7 @@ function UI.Window:pointToChild(x, y)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
UI.Window.docs.getFocusables = [[getxables(VOID)
|
UI.Window.docs.getFocusables = [[getFocusables(VOID)
|
||||||
Returns a list of children that can accept focus.]]
|
Returns a list of children that can accept focus.]]
|
||||||
function UI.Window:getFocusables()
|
function UI.Window:getFocusables()
|
||||||
local focusable = { }
|
local focusable = { }
|
||||||
|
|
|
@ -74,7 +74,9 @@ function UI.TextEntry:draw()
|
||||||
text = self.shadowText
|
text = self.shadowText
|
||||||
end
|
end
|
||||||
|
|
||||||
self:write(1, 1, ' ' .. Util.widthify(text, self.width - 2) .. ' ', bg, tc)
|
local ss = self.entry.scroll > 0 and '\183' or ' '
|
||||||
|
self:write(2, 1, Util.widthify(text, self.width - 2) .. ' ', bg, tc)
|
||||||
|
self:write(1, 1, ss, bg, self.shadowTextColor)
|
||||||
|
|
||||||
if self.entry.mark.active then
|
if self.entry.mark.active then
|
||||||
local tx = math.max(self.entry.mark.x - self.entry.scroll, 0)
|
local tx = math.max(self.entry.mark.x - self.entry.scroll, 0)
|
||||||
|
|
Loading…
Reference in New Issue