source: titan/titan/textinput.h @ 24223

Last change on this file since 24223 was 23702, checked in by nit, 11 years ago

[titan] cleanup

File size: 1.8 KB
Line 
1#ifndef TEXTINPUT_H
2#define TEXTINPUT_H
3
4char* textinput(char* title, char* text)
5{
6        int rcret = -1, fromthread = 0, height = 0;
7        struct skin* textinput = getscreen("textinput");
8        struct skin* input = getscreennode(textinput, "input");
9        struct skin* framebuffer = getscreen("framebuffer");
10        char* ret = NULL, *bg = NULL;
11
12        if(pthread_self() != status.mainthread)
13                fromthread = 1;
14
15        changetitle(textinput, title);
16        height = textinput->height;
17        if(title != NULL)
18                textinput->height += textinput->fontsize + 6 + (textinput->bordersize * 2);
19        changeinput(input, text);
20
21        if(fromthread == 1)
22        {
23                delrc(getrcconfigint("rcvolup", NULL), NULL, NULL);
24                delrc(getrcconfigint("rcvoldown", NULL), NULL, NULL);
25                delrc(getrcconfigint("rcmute", NULL), NULL, NULL);
26                m_lock(&status.drawingmutex, 0);
27                m_lock(&status.rcmutex, 10);
28                setnodeattr(textinput, framebuffer, 2);
29                status.rcowner = textinput;
30                bg = savescreen(textinput);
31                drawscreen(textinput, 0, 2);
32        }
33        else
34                drawscreen(textinput, 0, 0);
35        addscreenrc(textinput, input);
36
37        while(1)
38        {
39                rcret = waitrc(textinput, 0, 0);
40                if(rcret == getrcconfigint("rcexit", NULL)) break;
41                if(rcret == getrcconfigint("rcok", NULL))
42                {
43                        ret = ostrcat(input->input, NULL, 0, 0);
44                        break;
45                }
46        }
47
48        delownerrc(textinput);
49
50        if(fromthread == 1)
51        {
52                clearscreennolock(textinput);
53                restorescreen(bg, textinput);
54                blitfb(0);
55                sleep(1);
56                status.rcowner = NULL;
57                m_unlock(&status.rcmutex, 3);
58                m_unlock(&status.drawingmutex, 0);
59                addrc(getrcconfigint("rcvolup", NULL), screenvolumeup, NULL, NULL);
60                addrc(getrcconfigint("rcvoldown", NULL), screenvolumedown, NULL, NULL);
61                addrc(getrcconfigint("rcmute", NULL), screenmute, NULL, NULL);
62        }
63        else
64        {
65                clearscreen(textinput);
66                drawscreen(skin, 0, 0);
67        }
68
69        textinput->height = height;
70        return ret;
71}
72
73#endif
Note: See TracBrowser for help on using the repository browser.