Hi,
a functional test scripts for testing
Best,
Ola
*require "iuplua"
require "iuplua_scintilla"
ed = iup.scintilla{EXPAND = "YES", FONT="ARIAL, 16",
tip = 'type "ab" in sequence will show auto-completion list, then Enter.
OK!'}
dlg = iup.dialog{ed, TITLE = "AUTOCSHOW", SIZE = "300x200"}
dlg:showxy(10,100)
savepos = 0
ed.valuechanged_cb = function()
auto =
ed["CHAR"..tostring(savepos-1)]..ed["CHAR"..tostring(savepos)]
end
ed.autocselection_cb = function(self, pos, text)
iup.SetAttributeId(ed, "INSERT", pos, text)
end
ed.caret_cb = function(self, lin, col, pos)
savepos = pos
-----
if auto == "ab" then
---- "id" defines the number
of characters of the word already entered by user.
ed["AUTOCSHOW".."2"] = "abCDEF"
auto = ""
end
end
if (iup.MainLoopLevel() == 0) then
iup.MainLoop()
end
*
Den 2016-03-14 kl. 19:41, skrev Antonio Scuri:
The caret will be updated only after the value changed callback is
processed. So I think you should rely on the CARET_CB callback for
caret updates instead of valuechanged_cb.
Best,
Scuri
On Sun, Mar 13, 2016 at 6:01 AM, 云履 <[email protected]
<mailto:[email protected]>> wrote:
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=278785231&iu=/4140
_______________________________________________
Iup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/iup-users
------------------------------------------------------------------------------
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=278785231&iu=/4140
_______________________________________________
Iup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/iup-users