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