1 | #ifndef TEXTINPUT_H |
---|
2 | #define TEXTINPUT_H |
---|
3 | |
---|
4 | char* 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 | if(title == NULL) title = ostrcat(_("Input field"), NULL, 0, 0); |
---|
16 | |
---|
17 | changetitle(textinput, title); |
---|
18 | height = textinput->height; |
---|
19 | if(title != NULL) |
---|
20 | textinput->height += textinput->fontsize + 6 + (textinput->bordersize * 2); |
---|
21 | changeinput(input, text); |
---|
22 | |
---|
23 | if(fromthread == 1) |
---|
24 | { |
---|
25 | delrc(getrcconfigint("rcvolup", NULL), NULL, NULL); |
---|
26 | delrc(getrcconfigint("rcvoldown", NULL), NULL, NULL); |
---|
27 | delrc(getrcconfigint("rcmute", NULL), NULL, NULL); |
---|
28 | m_lock(&status.drawingmutex, 0); |
---|
29 | m_lock(&status.rcmutex, 10); |
---|
30 | setnodeattr(textinput, framebuffer, 2); |
---|
31 | status.rcowner = textinput; |
---|
32 | bg = savescreen(textinput); |
---|
33 | drawscreen(textinput, 0, 2); |
---|
34 | } |
---|
35 | else |
---|
36 | drawscreen(textinput, 0, 0); |
---|
37 | addscreenrc(textinput, input); |
---|
38 | |
---|
39 | while(1) |
---|
40 | { |
---|
41 | rcret = waitrc(textinput, 0, 0); |
---|
42 | if(rcret == getrcconfigint("rcexit", NULL)) break; |
---|
43 | if(rcret == getrcconfigint("rcok", NULL)) |
---|
44 | { |
---|
45 | ret = ostrcat(input->input, NULL, 0, 0); |
---|
46 | break; |
---|
47 | } |
---|
48 | } |
---|
49 | |
---|
50 | delownerrc(textinput); |
---|
51 | |
---|
52 | if(fromthread == 1) |
---|
53 | { |
---|
54 | clearscreennolock(textinput); |
---|
55 | restorescreen(bg, textinput); |
---|
56 | blitfb(0); |
---|
57 | sleep(1); |
---|
58 | status.rcowner = NULL; |
---|
59 | m_unlock(&status.rcmutex, 3); |
---|
60 | m_unlock(&status.drawingmutex, 0); |
---|
61 | addrc(getrcconfigint("rcvolup", NULL), screenvolumeup, NULL, NULL); |
---|
62 | addrc(getrcconfigint("rcvoldown", NULL), screenvolumedown, NULL, NULL); |
---|
63 | addrc(getrcconfigint("rcmute", NULL), screenmute, NULL, NULL); |
---|
64 | } |
---|
65 | else |
---|
66 | { |
---|
67 | clearscreen(textinput); |
---|
68 | drawscreen(skin, 0, 0); |
---|
69 | } |
---|
70 | |
---|
71 | textinput->height = height; |
---|
72 | return ret; |
---|
73 | } |
---|
74 | |
---|
75 | #endif |
---|