Hi All,
I have made a virtual terminal like app in iuplua (but question refers to iup!
not lua), which read & evaluate inputs prompted to user.
I have a problem in the iupmultiline. when enter pressed the vertical cursor
goes on the next line instead of "> " line.The cursor should be shown like this
"> |". Below is the program:
-- A Virtual Terminal Using IupMultiline
-- Copyright (c) 2013 Muhammad Asif Hussain
require( "iuplua" )
i = 0 -- flag for chars count
ml = iup.multiline{
EXPAND = "YES",
BGCOLOR = "255 255 255",
FGCOLOR = "0 0 0",
APPENDNEWLINE = "NO"
}
-- mouse buttons callback
function ml:button_cb(but, pressed, x, y, status)
print(but)
print(pressed)
print(x)
print(y)
print(status)
if but==49 then
return iup.IGNORE
else
return iup.DEFAULT
end
end
dlg = iup.dialog{ml; title="My Virtual Terminal", size="HALFxHALF"}
dlg:show()
ml.insert = " My Virtual Terminal \n"
ml.insert = "> " -- prompt for input
-- ********************************** check key presses
*******************************
function ml:k_any(c)
-- neglect arrow keys
--
if c == iup.K_UP or c == iup.K_LEFT or c == iup.K_RIGHT or c ==
iup.K_DOWN then
return iup.IGNORE
end
-- handle input, allow user for current line editing using i flag
if c == iup.K_CR then
i = 0
COM = ml.linevalue
Split(COM)
ml.insert = "\n> "
return iup.DEFAULT
else
if c ~= iup.K_BS then
i = i + 1
return iup.DEFAULT;
end
end
-- hanle current line editing
if c == iup.K_BS then
if i == 0 then
return iup.IGNORE
else
i = i - 1
return iup.DEFAULT
end
end
end -- function ended
-- ****************************************************************
if (iup.MainLoopLevel()==0) then
iup.MainLoop()
end
-- ***************** SPLIT FUNCTION ********************
function Split(str)
tokens = {}
for w in string.gmatch( str, "(%w+)" ) do
tokens[#tokens+1] = w
end
if str ~= "" then
ml.insert = "\n"
end
for i = 1, #tokens do
print( tokens[i] )
ml.insert = tokens[i]
end
end
I think newline is built in the iupmultiline when enter pressed. how this could
be controlled?
Regards,
Muhammad Asif Hussain
___________________________________________________________________
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Iup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/iup-users