Attribute "Caretpos" in scintilla may need update automatically in
valuechanged_cb. Which affect Auto-Completion.
In other words, Auto-Completion won't work correct, if set it within callback
ACTION or VALUECHANGED_CB in some case.
Demo with Tip and comment.
local iup = require ("iuplua")
require"iuplua_scintilla"
local offset_caretPos
iup.dialog{
iup.scintilla{
tip = 'type "ab" in sequence will show auto-completion list, then
Enter, but "ab" wont expand to "abcd".',
valuechanged_cb = function(self)
print('caretpos = '..self.caretpos) --Although this is
triggered after content change,
--but its caret pos is still un-update, if it is a
insert opperate
--self.caretpos = self.caretpos + offset_caretPos --This
is the final caret pos.
-- need to update/fix 'caretpos', or the below test will
fail.
--Caret pos affect Auto-Completion
if self.value == 'ab' then
self['AUTOCSHOW'..tostring(string.len(self.value))] =
'abcd'
print('Autocposstart is '..self.AUTOCPOSSTART..', which
is the pos after "a" - "'.. self.caretpos ..'" - the previous caret pos after
input "a", "b" sequencely.\nAnd it should be 2, which equal
"string.len(self.value)" in this case.\nGo on "Enter".')
end
end,
action = function(self, mode, pos, length, text)
offset_caretPos = mode == 1 and length or 0 --mode == 1:
inserted
end,
autocselection_cb = function(self, pos, text)
print('autocselection_cb', 'autocposstart =
'..self.autocposstart, 'pos = ' .. pos, text)
-- (If won't update the caretpos.) The 'pos' is -1, which
is incorrect here.
end,
}
}:show()
iup.MainLoop()
I'm not sure if this work should be done by Scintilla or iup.
Best,
Robert Lin------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785111&iu=/4140
_______________________________________________
Iup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/iup-users