I want to use IupText to be a message output console, when message append
to IupText, I want to scroll to the bottom of IupText. I try the following
code, but it didn't work.

[code]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iup.h>

Ihandle *txt_message;

int cb_timer(Ihandle *self)
{
    static int val;
    int line_cnt;

    IupSetStrf(txt_message, "APPEND", "[%d]TEST TXT\n\r", val++);
    line_cnt = IupGetInt(txt_message, "LINECOUNT");
    IupSetStrf(txt_message, "SCROLLTO", "%d:1", line_cnt);

    return IUP_DEFAULT;
}

void create_main_dialog(void)
{
    Ihandle *dlg;
    Ihandle *timer;

    timer = IupTimer();
    IupSetInt(timer, "TIME", 100);
    IupSetCallback(timer, "ACTION_CB", (Icallback)cb_timer);
    IupSetAttribute(timer, "RUN", "YES");

    txt_message = IupText(NULL);
    IupSetAttribute(txt_message, "EXPAND", "YES");
    IupSetAttribute(txt_message, "READONLY", "YES");
    IupSetAttribute(txt_message, "MULTILINE", "YES");
    IupSetAttribute(txt_message, "APPENDNEWLINE", "NO");

    dlg = IupDialog(
            IupSetAttributes(IupVbox(
                    txt_message,
                    NULL), "NMARGIN=10x10,GAP=10")
            );

    IupSetAttribute(dlg, "TITLE", "RTT STLINK");
    IupSetAttribute(dlg, "RASTERSIZE", "800x600");
    IupShowXY(dlg, IUP_CENTER, IUP_CENTER);
}

int main(int ac, char** av)
{
    IupOpen(&ac, &av);

    create_main_dialog();
    IupMainLoop();

    IupClose();
    return 0;
}
[/code]

Iup 3.25, linux 4.47, gtk+3.0
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Iup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/iup-users

Reply via email to