luatextboxiup

LUA iup.text cursor trouble


I am trying to use iup.text to create a textbox linked to a text file. I want to display the text file in this textbox in real time.

local Visu = iup.text{ 
    multiline="yes", 
    --rastersize="x60", 
    expand="yes",
    readonly="yes", 
    --font="Times, Bold 12",
    SCROLLBAR="YES",
    AUTOHIDE="YES",
    BGCOLOR="0 43 54",
    fgcolor="255 255 255",
    --maxsize="x1000",
}
function refresh_txt()
    local f2 = io.open("txtfile.txt", "r")
    if not f2 then 
        Visu.value = "Empty File" 
    else
        Visu.value = f2:read("*a")
    end
end

The problem is, when the textbox is just actualized by the function refresh_txt()` the cursor is put at the beginning of the showed text and not at the end of the text as I want. So the text is constantly being refreshed and I can't scroll down because when I did it, the cursor goes to the first character of the first line.

I want an automatic vertical expand of the textbox when refreshed.

I think that the problem can be solved by some argument of iup.text, but I didn't found it.


Solution

  • To scroll down after changing the text use VisuQSPI.scrollto = "99999999:1".