Mon, 15 Dec 2014 22:36:14 +0200
- cleanup, fixed red text not rendering
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | Copyright 2014 Teemu Piippo |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | All rights reserved. |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | Redistribution and use in source and binary forms, with or without |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | modification, are permitted provided that the following conditions |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | are met: |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | 1. Redistributions of source code must retain the above copyright |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | notice, this list of conditions and the following disclaimer. |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | 2. Redistributions in binary form must reproduce the above copyright |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | notice, this list of conditions and the following disclaimer in the |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | documentation and/or other materials provided with the distribution. |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | 3. Neither the name of the copyright holder nor the names of its |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | contributors may be used to endorse or promote products derived from |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | this software without specific prior written permission. |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | */ |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | #include <string.h> |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | #include "interface.h" |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
33 | #include "network/rconsession.h" |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
34 | #include "network/ipaddress.h" |
46
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
35 | #include "coloredline.h" |
34
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
36 | |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
37 | static const int g_pageSize = 10; |
16
33bac54867bf
- added backlog scrolling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
38 | |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
39 | enum InputState |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
40 | { |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
41 | INPUTSTATE_NORMAL, |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
42 | INPUTSTATE_ADDRESS, |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
43 | INPUTSTATE_PASSWORD, |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
44 | INPUTSTATE_CONFIRM_DISCONNECTION, |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
45 | }; |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
46 | |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
47 | static StringList g_input; |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
48 | static int g_inputCursor = 0; |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | static int g_cursor = 0; |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | static int g_pan = 0; |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | static bool g_needRefresh = false; |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
52 | static bool g_needStatusBarRender = false; |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
53 | static bool g_needInputRender = false; |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
54 | static bool g_needOutputRender = false; |
47 | 55 | static bool g_needNicklistRender = false; |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
56 | static struct { char ch; int x; } g_cursorChar; |
46
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
57 | static Vector<ColoredLine> g_output;; |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
58 | static int g_outputScroll = 0; |
23
f7221183a994
- the prompt is now colored
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
59 | static String g_title; |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
60 | static InputState g_inputState = INPUTSTATE_NORMAL; |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
61 | static Function<void (void)> g_disconnectConfirmFunction = nullptr; |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
62 | static IPAddress g_address; |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
63 | static String g_statusBarText; |
47 | 64 | static StringList g_playerNames; |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | // ------------------------------------------------------------------------------------------------- |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | // |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | static FUNCTION |
20
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
69 | interface_color_pair (Color fg, Color bg) -> int |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
70 | { |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
71 | return COLOR_PAIR ((int (fg) * NUM_COLORS) + int (bg)); |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
72 | } |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
73 | |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
74 | // ------------------------------------------------------------------------------------------------- |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
75 | // |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
76 | static FUNCTION |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
77 | current_input() -> const String& |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
78 | { |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
79 | return g_input[g_inputCursor]; |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
80 | } |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
81 | |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
82 | // ------------------------------------------------------------------------------------------------- |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
83 | // |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
84 | // Makes current_input() the lastmost input (so that we won't modify history) |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
85 | // |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
86 | static FUNCTION |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
87 | detach_input() -> void |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
88 | { |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
89 | if (g_inputCursor > 0) |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
90 | { |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
91 | g_input[0] = current_input(); |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
92 | g_inputCursor = 0; |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
93 | } |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
94 | } |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
95 | |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
96 | // ------------------------------------------------------------------------------------------------- |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
97 | // A version of current_input() that allows changing the contents of it. |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
98 | // |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
99 | static FUNCTION |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
100 | mutable_current_input() -> String& |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
101 | { |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
102 | detach_input(); |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
103 | return g_input[g_inputCursor]; |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
104 | } |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
105 | |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
106 | // ------------------------------------------------------------------------------------------------- |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
107 | // |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
108 | static FUNCTION |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
109 | move_input_cursor (int delta) -> void |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
110 | { |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
111 | // No input history when inputting addresses or passwords |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
112 | if (g_inputState != INPUTSTATE_NORMAL) |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
113 | { |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
114 | g_inputCursor = 0; |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
115 | return; |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
116 | } |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
117 | |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
118 | int oldcursor = g_inputCursor; |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
119 | g_inputCursor = clamp (g_inputCursor + delta, 0, g_input.size() - 1); |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
120 | |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
121 | if (g_inputCursor != oldcursor) |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
122 | { |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
123 | g_cursor = current_input().length(); |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
124 | g_needInputRender = true; |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
125 | } |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
126 | } |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
127 | |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
128 | // ------------------------------------------------------------------------------------------------- |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
129 | // |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
130 | static FUNCTION |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
131 | interface_prompt_string() -> String |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
132 | { |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
133 | String prompt; |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
134 | |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
135 | switch (g_inputState) |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
136 | { |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
137 | case INPUTSTATE_NORMAL: prompt = ">"; break; |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
138 | case INPUTSTATE_ADDRESS: prompt = "address:"; break; |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
139 | case INPUTSTATE_PASSWORD: prompt = "password:"; break; |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
140 | case INPUTSTATE_CONFIRM_DISCONNECTION: break; |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
141 | } |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
142 | |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
143 | return prompt; |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
144 | } |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
145 | |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
146 | // ------------------------------------------------------------------------------------------------- |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
147 | // |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
148 | static FUNCTION |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
149 | set_input_state (InputState newstate) -> void |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
150 | { |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
151 | // Clear the input row (unless going to or from confirm state) |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
152 | if (newstate != INPUTSTATE_CONFIRM_DISCONNECTION |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
153 | and g_inputState != INPUTSTATE_CONFIRM_DISCONNECTION) |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
154 | { |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
155 | g_inputCursor = 0; |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
156 | mutable_current_input().clear(); |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
157 | } |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
158 | |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
159 | switch (newstate) |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
160 | { |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
161 | case INPUTSTATE_ADDRESS: |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
162 | if (g_address.host != 0) |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
163 | mutable_current_input() = g_address.to_string (IP_WITH_PORT); |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
164 | break; |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
165 | |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
166 | default: |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
167 | break; |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
168 | } |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
169 | |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
170 | g_inputState = newstate; |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
171 | g_needInputRender = true; |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
172 | } |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
173 | |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
174 | // ------------------------------------------------------------------------------------------------- |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
175 | // |
20
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
176 | FUNCTION |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
177 | Interface::initialize() -> void |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
178 | { |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
179 | ::initscr(); |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
180 | ::start_color(); |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
181 | ::raw(); |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
182 | ::keypad (stdscr, true); |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
183 | ::noecho(); |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
184 | ::refresh(); |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
185 | ::timeout (0); |
30
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
186 | ::use_default_colors(); |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
187 | g_input.clear(); |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
188 | g_input << ""; |
34
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
189 | g_output.clear(); |
46
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
190 | g_output << ColoredLine(); |
23
f7221183a994
- the prompt is now colored
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
191 | g_title = format (APPNAME " %1 (%2)", full_version_string(), changeset_date_string()); |
20
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
192 | |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
193 | for (int i = 0; i < NUM_COLORS; ++i) |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
194 | for (int j = 0; j < NUM_COLORS; ++j) |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
195 | { |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
196 | init_pair ((i * NUM_COLORS + j), |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
197 | (i == DEFAULT) ? -1 : i, |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
198 | (j == DEFAULT) ? -1 : j); |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
199 | } |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
200 | |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
201 | render_full(); |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
202 | refresh(); |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
203 | g_needRefresh = false; |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
204 | } |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
205 | |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
206 | // ------------------------------------------------------------------------------------------------- |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
207 | // |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
208 | static FUNCTION |
23
f7221183a994
- the prompt is now colored
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
209 | interface_render_titlebar() -> void |
20
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
210 | { |
23
f7221183a994
- the prompt is now colored
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
211 | if (g_title.length() <= COLS) |
f7221183a994
- the prompt is now colored
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
212 | { |
f7221183a994
- the prompt is now colored
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
213 | int pair = interface_color_pair (WHITE, BLUE); |
f7221183a994
- the prompt is now colored
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
214 | int startx = (COLS - g_title.length()) / 2; |
f7221183a994
- the prompt is now colored
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
215 | int endx = startx + g_title.length(); |
f7221183a994
- the prompt is now colored
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
216 | attron (pair); |
f7221183a994
- the prompt is now colored
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
217 | mvprintw (0, startx, "%s", g_title.chars()); |
f7221183a994
- the prompt is now colored
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
218 | mvhline (0, 0, ' ', startx); |
f7221183a994
- the prompt is now colored
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
219 | mvhline (0, endx, ' ', COLS - endx); |
f7221183a994
- the prompt is now colored
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
220 | attroff (pair); |
f7221183a994
- the prompt is now colored
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
221 | } |
f7221183a994
- the prompt is now colored
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
222 | |
f7221183a994
- the prompt is now colored
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
223 | g_needRefresh = true; |
20
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
224 | } |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
225 | |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
226 | // ------------------------------------------------------------------------------------------------- |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
227 | // |
23
f7221183a994
- the prompt is now colored
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
228 | FUNCTION |
f7221183a994
- the prompt is now colored
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
229 | Interface::set_title (const String& title) -> void |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
230 | { |
23
f7221183a994
- the prompt is now colored
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
231 | g_title = title; |
f7221183a994
- the prompt is now colored
Teemu Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
232 | interface_render_titlebar(); |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
233 | } |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
234 | |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
235 | // ------------------------------------------------------------------------------------------------- |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
236 | // |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
237 | static FUNCTION |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
238 | safe_disconnect (Function<void()> afterwards) -> void |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
239 | { |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
240 | if (RCONSession::get_session()->is_active()) |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
241 | { |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
242 | g_disconnectConfirmFunction = afterwards; |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
243 | set_input_state (INPUTSTATE_CONFIRM_DISCONNECTION); |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
244 | } |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
245 | else |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
246 | afterwards(); |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
247 | } |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
248 | |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
249 | // ------------------------------------------------------------------------------------------------- |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
250 | // |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
251 | static FUNCTION |
48
02009f1ec2b7
- cleanup, fixed red text not rendering
Teemu Piippo <crimsondusk64@gmail.com>
parents:
47
diff
changeset
|
252 | interface_nicklist_width() -> int |
47 | 253 | { |
254 | // Allocate at least 12 characters, at most 24 characters, for the nicklist. If we cannot | |
255 | // afford that (o_O) then we probably shouldn't draw the nicklist at all I think. | |
256 | int nicklistWidth = COLS / 4; | |
257 | ||
258 | if (nicklistWidth < 12) | |
259 | return 0; | |
260 | ||
261 | return min (nicklistWidth, 24); | |
262 | } | |
263 | ||
264 | // ------------------------------------------------------------------------------------------------- | |
265 | // Renders the given colored line onto the screen. Will wrap if allowWrap is true. Returns the | |
266 | // 'y' value for the next line. | |
267 | // | |
268 | static FUNCTION | |
269 | interface_render_colorline (int y, int x0, int width, | |
270 | const ColoredLine& line, bool allowWrap) -> int | |
271 | { | |
272 | int x = x0; | |
273 | ||
274 | for (int byte : line.data()) | |
275 | { | |
276 | if (x == x0 + width) | |
277 | { | |
278 | if (not allowWrap) | |
279 | return y; | |
280 | ||
281 | x = x0; | |
282 | ++y; | |
283 | } | |
284 | ||
285 | if (isprint (byte)) | |
286 | { | |
287 | mvaddch (y, x, char (byte)); | |
288 | ++x; | |
289 | } | |
290 | else switch (byte) | |
291 | { | |
292 | case RLINE_ON_BLACK: | |
48
02009f1ec2b7
- cleanup, fixed red text not rendering
Teemu Piippo <crimsondusk64@gmail.com>
parents:
47
diff
changeset
|
293 | case RLINE_ON_RED: |
47 | 294 | case RLINE_ON_GREEN: |
295 | case RLINE_ON_YELLOW: | |
296 | case RLINE_ON_BLUE: | |
297 | case RLINE_ON_MAGENTA: | |
298 | case RLINE_ON_CYAN: | |
299 | case RLINE_ON_WHITE: | |
300 | attron (interface_color_pair (Color (byte - RLINE_ON_BLACK), DEFAULT)); | |
301 | break; | |
302 | ||
303 | case RLINE_OFF_BLACK: | |
48
02009f1ec2b7
- cleanup, fixed red text not rendering
Teemu Piippo <crimsondusk64@gmail.com>
parents:
47
diff
changeset
|
304 | case RLINE_OFF_RED: |
47 | 305 | case RLINE_OFF_GREEN: |
306 | case RLINE_OFF_YELLOW: | |
307 | case RLINE_OFF_BLUE: | |
308 | case RLINE_OFF_MAGENTA: | |
309 | case RLINE_OFF_CYAN: | |
310 | case RLINE_OFF_WHITE: | |
311 | attroff (interface_color_pair (Color (byte - RLINE_OFF_BLACK), DEFAULT)); | |
312 | break; | |
313 | ||
314 | case RLINE_ON_BOLD: | |
315 | attron (A_BOLD); | |
316 | break; | |
317 | ||
318 | case RLINE_OFF_BOLD: | |
319 | attroff (A_BOLD); | |
320 | break; | |
321 | } | |
322 | } | |
323 | ||
324 | return y + 1; | |
325 | } | |
326 | ||
327 | // ------------------------------------------------------------------------------------------------- | |
328 | // | |
329 | static FUNCTION | |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
330 | interface_render_output() -> void |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
331 | { |
34
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
332 | if (g_output.size() == 1) |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
333 | return; |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
334 | |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
335 | g_outputScroll = clamp (g_outputScroll, 0, g_output.size() - 1); |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
336 | |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
337 | int height = LINES - 3; |
48
02009f1ec2b7
- cleanup, fixed red text not rendering
Teemu Piippo <crimsondusk64@gmail.com>
parents:
47
diff
changeset
|
338 | int width = COLS - interface_nicklist_width(); |
34
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
339 | int printOffset = 0; |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
340 | int end = g_output.size() - 1 - g_outputScroll; |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
341 | int start = end; |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
342 | int usedHeight = 0; |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
343 | int y = 1; |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
344 | bool tightFit = false; |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
345 | |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
346 | // Where to start? |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
347 | while (start > 0) |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
348 | { |
47 | 349 | int rows = g_output[start - 1].rows (width); |
34
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
350 | |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
351 | if (usedHeight + rows > height) |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
352 | { |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
353 | // This line won't fit anymore. |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
354 | tightFit = true; |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
355 | break; |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
356 | } |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
357 | |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
358 | start--; |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
359 | usedHeight += rows; |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
360 | } |
16
33bac54867bf
- added backlog scrolling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
361 | |
34
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
362 | // See if there's any more rows to use (end may be too small) |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
363 | if (not tightFit) |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
364 | { |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
365 | while (end < g_output.size()) |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
366 | { |
47 | 367 | int rows = g_output[end].rows (width); |
34
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
368 | |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
369 | if (usedHeight + rows > height) |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
370 | { |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
371 | tightFit = true; |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
372 | break; |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
373 | } |
16
33bac54867bf
- added backlog scrolling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
374 | |
34
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
375 | end++; |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
376 | usedHeight += rows; |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
377 | } |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
378 | } |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
379 | |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
380 | if (start > 0) |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
381 | printOffset = height - usedHeight; |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
382 | |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
383 | g_outputScroll = g_output.size() - 1 - end; |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
384 | |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
385 | if (start < 0 or start == end or printOffset >= height) |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
386 | return; |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
387 | |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
388 | assert (start <= end and start - end <= height); |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
389 | |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
390 | // Clear the display |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
391 | for (int i = y; i < y + height; ++i) |
47 | 392 | mvhline (i, 0, ' ', width); |
34
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
393 | |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
394 | // Print the lines |
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
395 | y += printOffset; |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
396 | |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
397 | for (int i = start; i < end; ++i) |
47 | 398 | y = interface_render_colorline (y, 0, width, g_output[i], true); |
399 | ||
400 | g_needOutputRender = false; | |
401 | g_needRefresh = true; | |
402 | } | |
403 | ||
404 | // ------------------------------------------------------------------------------------------------- | |
405 | // | |
406 | static FUNCTION | |
407 | interface_render_nicklist() -> void | |
408 | { | |
48
02009f1ec2b7
- cleanup, fixed red text not rendering
Teemu Piippo <crimsondusk64@gmail.com>
parents:
47
diff
changeset
|
409 | int width = interface_nicklist_width(); |
47 | 410 | int height = LINES- 3; |
411 | int y = 1; | |
412 | int x = COLS - width; | |
413 | ||
414 | if (width == 0) | |
415 | return; | |
416 | ||
417 | for (int i = 0; i < height; ++i) | |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
418 | { |
47 | 419 | mvhline (y, x, ' ', width); |
32
ee770597a281
- added support for in-game colors
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
420 | |
47 | 421 | if (i < g_playerNames.size()) |
32
ee770597a281
- added support for in-game colors
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
422 | { |
47 | 423 | String displaynick = g_playerNames[i]; |
424 | ||
425 | if (displaynick.length() > width) | |
32
ee770597a281
- added support for in-game colors
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
426 | { |
47 | 427 | displaynick = displaynick.mid (0, width - 3); |
428 | displaynick += "..."; | |
32
ee770597a281
- added support for in-game colors
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
429 | } |
ee770597a281
- added support for in-game colors
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
430 | |
47 | 431 | mvprintw (y, x, "%s", displaynick.chars()); |
34
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
432 | } |
32
ee770597a281
- added support for in-game colors
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
433 | |
47 | 434 | y++; |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
435 | } |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
436 | |
47 | 437 | g_needNicklistRender = false; |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
438 | g_needRefresh = true; |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
439 | } |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
440 | |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
441 | // ------------------------------------------------------------------------------------------------- |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
442 | // |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
443 | static FUNCTION |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
444 | interface_render_input() -> void |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
445 | { |
25
88b41eea08e0
- cleanup, refactor + better input handling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
446 | int promptColor = interface_color_pair (WHITE, BLUE); |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
447 | |
25
88b41eea08e0
- cleanup, refactor + better input handling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
448 | // If we're asking the user if they want to disconnect, we don't render any input strings, |
88b41eea08e0
- cleanup, refactor + better input handling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
449 | // just the confirmation message. |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
450 | if (g_inputState == INPUTSTATE_CONFIRM_DISCONNECTION) |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
451 | { |
25
88b41eea08e0
- cleanup, refactor + better input handling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
452 | attron (promptColor); |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
453 | mvhline (LINES - 2, 0, ' ', COLS); |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
454 | mvprintw (LINES - 2, 0, "Are you sure you want to disconnect? y/n"); |
25
88b41eea08e0
- cleanup, refactor + better input handling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
455 | attroff (promptColor); |
45
87b180260a5d
- fixed: invoking the 'are you sure you want to disconnect?' message did not trigger a screen refresh
Teemu Piippo <crimsondusk64@gmail.com>
parents:
44
diff
changeset
|
456 | g_needRefresh = true; |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
457 | return; |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
458 | } |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
459 | |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
460 | String prompt = interface_prompt_string(); |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
461 | int displayLength = COLS - prompt.length() - 2; |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
462 | String displayString = current_input(); |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
463 | int y = LINES - 2; |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
464 | |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
465 | // If we're inputting a password, replace it with asterisks |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
466 | if (g_inputState == INPUTSTATE_PASSWORD) |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
467 | { |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
468 | for (char& ch : displayString) |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
469 | ch = '*'; |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
470 | } |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
471 | |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
472 | // Ensure the cursor is within bounds |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
473 | g_cursor = clamp (g_cursor, 0, displayString.length()); |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
474 | |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
475 | // Ensure that the cursor is always in view, adjust panning if this is not the case |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
476 | if (g_cursor > g_pan + displayLength) |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
477 | g_pan = g_cursor - displayLength; // cursor went too far right |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
478 | else if (g_cursor < g_pan) |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
479 | g_pan = g_cursor; // cursor went past the pan value to the left |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
480 | |
25
88b41eea08e0
- cleanup, refactor + better input handling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
481 | // What part of the string to draw? |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
482 | int start = g_pan; |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
483 | int end = min<int> (displayString.length(), start + displayLength); |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
484 | assert (g_cursor >= start and g_cursor <= end); |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
485 | |
25
88b41eea08e0
- cleanup, refactor + better input handling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
486 | // Render the input string |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
487 | mvhline (LINES - 2, 0, ' ', COLS); |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
488 | mvprintw (y, prompt.length() + 1, "%s", displayString.chars()); |
25
88b41eea08e0
- cleanup, refactor + better input handling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
489 | |
88b41eea08e0
- cleanup, refactor + better input handling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
490 | // Render the prompt |
88b41eea08e0
- cleanup, refactor + better input handling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
491 | attron (promptColor); |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
492 | mvprintw (y, 0, "%s", prompt.chars()); |
25
88b41eea08e0
- cleanup, refactor + better input handling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
493 | attroff (promptColor); |
88b41eea08e0
- cleanup, refactor + better input handling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
494 | |
88b41eea08e0
- cleanup, refactor + better input handling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
495 | // Store in memory where the cursor is now (so that we can re-draw it to position the terminal |
88b41eea08e0
- cleanup, refactor + better input handling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
496 | // cursor). |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
497 | g_cursorChar.ch = g_cursor != 0 ? displayString[g_cursor - 1] : '\0'; |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
498 | g_cursorChar.x = prompt.length() + (g_cursor - g_pan); |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
499 | g_needRefresh = true; |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
500 | g_needInputRender = false; |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
501 | } |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
502 | |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
503 | // ------------------------------------------------------------------------------------------------- |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
504 | // |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
505 | static FUNCTION |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
506 | interface_render_statusbar() -> void |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
507 | { |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
508 | int color = interface_color_pair (WHITE, BLUE); |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
509 | int y = LINES - 1; |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
510 | attron (color); |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
511 | mvhline (y, 0, ' ', COLS); |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
512 | mvprintw (y, 0, "%s", g_statusBarText.chars()); |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
513 | attroff (color); |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
514 | g_needRefresh = true; |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
515 | g_needStatusBarRender = false; |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
516 | } |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
517 | |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
518 | // ------------------------------------------------------------------------------------------------- |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
519 | // |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
520 | FUNCTION |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
521 | Interface::update_statusbar() -> void |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
522 | { |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
523 | String text; |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
524 | RCONSession* session = RCONSession::get_session(); |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
525 | |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
526 | switch (session->state()) |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
527 | { |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
528 | case RCON_DISCONNECTED: |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
529 | text = "Disconnected."; |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
530 | break; |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
531 | |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
532 | case RCON_CONNECTING: |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
533 | case RCON_AUTHENTICATING: |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
534 | text = "Connecting to " + session->address().to_string (IP_WITH_PORT) + "..."; |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
535 | break; |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
536 | |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
537 | case RCON_CONNECTED: |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
538 | { |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
539 | String adminText = (session->num_admins() == 0) ? "No other admins" |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
540 | : format ("%1 other admin%s1", session->num_admins()); |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
541 | text = format ("%1 | %2 | %3", session->address().to_string (IP_WITH_PORT), |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
542 | session->level(), adminText); |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
543 | } |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
544 | break; |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
545 | } |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
546 | |
28
3cc042af3090
- added a help message to the statusbar
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
547 | if (not text.is_empty()) |
3cc042af3090
- added a help message to the statusbar
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
548 | text += " | "; |
3cc042af3090
- added a help message to the statusbar
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
549 | |
3cc042af3090
- added a help message to the statusbar
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
550 | text += "^N to connect, ^Q to quit"; |
3cc042af3090
- added a help message to the statusbar
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
551 | |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
552 | if (text != g_statusBarText) |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
553 | { |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
554 | g_statusBarText = text; |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
555 | g_needStatusBarRender = true; |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
556 | } |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
557 | } |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
558 | |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
559 | // ------------------------------------------------------------------------------------------------- |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
560 | // |
20
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
561 | FUNCTION |
5f8cdc8febbb
- now in color! (titlebar at least anyway)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
562 | Interface::render_full() -> void |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
563 | { |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
564 | update_statusbar(); |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
565 | interface_render_titlebar(); |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
566 | interface_render_output(); |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
567 | interface_render_statusbar(); |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
568 | interface_render_input(); |
47 | 569 | interface_render_nicklist(); |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
570 | } |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
571 | |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
572 | // ------------------------------------------------------------------------------------------------- |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
573 | // |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
574 | static FUNCTION |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
575 | interface_position_cursor() -> void |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
576 | { |
25
88b41eea08e0
- cleanup, refactor + better input handling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
577 | // This is only relevant if the input string is being drawn |
88b41eea08e0
- cleanup, refactor + better input handling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
578 | if (g_inputState == INPUTSTATE_CONFIRM_DISCONNECTION) |
88b41eea08e0
- cleanup, refactor + better input handling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
579 | return; |
88b41eea08e0
- cleanup, refactor + better input handling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
580 | |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
581 | int y = LINES - 2; |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
582 | |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
583 | if (g_cursorChar.ch != '\0') |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
584 | mvprintw (y, g_cursorChar.x, "%c", g_cursorChar.ch); |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
585 | else |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
586 | mvprintw (y, interface_prompt_string().length(), " "); |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
587 | } |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
588 | |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
589 | // ------------------------------------------------------------------------------------------------- |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
590 | // |
43
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
591 | static FUNCTION |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
592 | interface_find_previous_word() -> int |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
593 | { |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
594 | const String& input = current_input(); |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
595 | int pos = g_cursor; |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
596 | |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
597 | // Move past whitespace |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
598 | while (pos > 0 and isspace (input[pos - 1])) |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
599 | pos--; |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
600 | |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
601 | // Move past the word |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
602 | while (pos > 0 and not isspace (input[pos - 1])) |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
603 | pos--; |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
604 | |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
605 | return pos; |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
606 | } |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
607 | |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
608 | // ------------------------------------------------------------------------------------------------- |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
609 | // |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
610 | static FUNCTION |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
611 | interface_find_next_word() -> int |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
612 | { |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
613 | const String& input = current_input(); |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
614 | int pos = g_cursor; |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
615 | |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
616 | // Move past current whitespace |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
617 | while (pos < input.length() and isspace (input[pos])) |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
618 | pos++; |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
619 | |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
620 | // Move past the word |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
621 | while (input[pos] != '\0' and not isspace (input[pos])) |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
622 | pos++; |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
623 | |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
624 | return pos; |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
625 | } |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
626 | |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
627 | // ------------------------------------------------------------------------------------------------- |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
628 | // |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
629 | FUNCTION |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
630 | Interface::handle_input() -> void |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
631 | { |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
632 | int ch = ::getch(); |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
633 | |
33
bb209480d0ec
- handle resizing 8-)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
634 | if (ch == KEY_RESIZE) |
bb209480d0ec
- handle resizing 8-)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
635 | { |
bb209480d0ec
- handle resizing 8-)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
636 | ::clear(); |
bb209480d0ec
- handle resizing 8-)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
637 | render_full(); |
bb209480d0ec
- handle resizing 8-)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
638 | return; |
bb209480d0ec
- handle resizing 8-)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
639 | } |
bb209480d0ec
- handle resizing 8-)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
640 | |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
641 | if (g_inputState == INPUTSTATE_CONFIRM_DISCONNECTION) |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
642 | { |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
643 | if (ch == 'y' or ch == 'Y') |
30
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
644 | { |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
645 | RCONSession::get_session()->disconnect(); |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
646 | g_disconnectConfirmFunction(); |
30
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
647 | } |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
648 | else if (ch == 'n' or ch == 'N') |
25
88b41eea08e0
- cleanup, refactor + better input handling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
649 | set_input_state (INPUTSTATE_NORMAL); |
30
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
650 | |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
651 | return; |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
652 | } |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
653 | |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
654 | if (ch >= 0x20 and ch <= 0x7E) |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
655 | { |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
656 | mutable_current_input().insert (g_cursor++, char (ch)); |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
657 | g_needInputRender = true; |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
658 | } |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
659 | else switch (ch) |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
660 | { |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
661 | case 'Q' - 'A' + 1: // ^Q |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
662 | switch (g_inputState) |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
663 | { |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
664 | case INPUTSTATE_CONFIRM_DISCONNECTION: |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
665 | break; |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
666 | |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
667 | case INPUTSTATE_NORMAL: |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
668 | safe_disconnect ([]() |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
669 | { |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
670 | RCONSession* session = RCONSession::get_session(); |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
671 | |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
672 | if (session->is_active()) |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
673 | { |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
674 | session->disconnect(); |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
675 | set_input_state (INPUTSTATE_NORMAL); |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
676 | } |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
677 | else |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
678 | { |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
679 | endwin(); |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
680 | throw Exitception(); |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
681 | } |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
682 | }); |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
683 | break; |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
684 | |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
685 | case INPUTSTATE_PASSWORD: |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
686 | set_input_state (INPUTSTATE_ADDRESS); |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
687 | break; |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
688 | |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
689 | case INPUTSTATE_ADDRESS: |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
690 | set_input_state (INPUTSTATE_NORMAL); |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
691 | } |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
692 | break; |
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
693 | |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
694 | case KEY_LEFT: |
42
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
695 | case 'B' - 'A' + 1: // readline ^B |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
696 | if (g_cursor > 0) |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
697 | { |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
698 | g_cursor--; |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
699 | g_needInputRender = true; |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
700 | } |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
701 | break; |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
702 | |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
703 | case KEY_RIGHT: |
42
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
704 | case 'F' - 'A' + 1: // readline ^F |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
705 | if (g_cursor < current_input().length()) |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
706 | { |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
707 | g_cursor++; |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
708 | g_needInputRender = true; |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
709 | } |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
710 | break; |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
711 | |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
712 | case KEY_DOWN: |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
713 | case KEY_UP: |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
714 | move_input_cursor (ch == KEY_DOWN ? -1 : 1); |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
715 | break; |
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
716 | |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
717 | case KEY_HOME: |
42
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
718 | case 'A' - 'A' + 1: // readline ^A |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
719 | if (g_cursor != 0) |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
720 | { |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
721 | g_cursor = 0; |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
722 | g_needInputRender = true; |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
723 | } |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
724 | break; |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
725 | |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
726 | case KEY_END: |
42
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
727 | case 'E' - 'A' + 1: // readline ^E |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
728 | if (g_cursor != current_input().length()) |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
729 | { |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
730 | g_cursor = current_input().length(); |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
731 | g_needInputRender = true; |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
732 | } |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
733 | break; |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
734 | |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
735 | case KEY_BACKSPACE: |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
736 | if (g_cursor > 0) |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
737 | { |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
738 | mutable_current_input().remove_at (--g_cursor); |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
739 | g_needInputRender = true; |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
740 | } |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
741 | break; |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
742 | |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
743 | case KEY_DC: |
42
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
744 | case 'D' - 'A' + 1: // readline ^D |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
745 | if (g_cursor < current_input().length()) |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
746 | { |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
747 | mutable_current_input().remove_at (g_cursor); |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
748 | g_needInputRender = true; |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
749 | } |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
750 | break; |
16
33bac54867bf
- added backlog scrolling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
751 | |
33bac54867bf
- added backlog scrolling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
752 | case KEY_PPAGE: |
34
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
753 | g_outputScroll += min (g_pageSize, LINES / 2); |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
754 | g_needOutputRender = true; |
16
33bac54867bf
- added backlog scrolling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
755 | break; |
33bac54867bf
- added backlog scrolling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
756 | |
33bac54867bf
- added backlog scrolling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
757 | case KEY_NPAGE: |
34
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
758 | g_outputScroll -= min (g_pageSize, LINES / 2); |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
759 | g_needOutputRender = true; |
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
760 | break; |
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
761 | |
42
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
762 | case 'U' - 'A' + 1: // readline ^U - delete from start to cursor |
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
763 | if (g_cursor > 0) |
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
764 | { |
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
765 | mutable_current_input().remove (0, g_cursor); |
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
766 | g_cursor = 0; |
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
767 | g_needInputRender = true; |
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
768 | } |
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
769 | break; |
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
770 | |
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
771 | case 'K' - 'A' + 1: // readline ^K - delete from cursor to end |
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
772 | if (g_cursor < current_input().length()) |
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
773 | { |
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
774 | String& input = mutable_current_input(); |
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
775 | input.remove (g_cursor, input.length() - g_cursor); |
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
776 | g_needInputRender = true; |
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
777 | } |
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
778 | break; |
9699687081df
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
779 | |
44
693d7751fff0
- added readline alt-d and ^w support (delete till word boundaries)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
780 | case 'W' - 'A' + 1: // readline ^W - delete from previous word bounary to current |
693d7751fff0
- added readline alt-d and ^w support (delete till word boundaries)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
781 | { |
693d7751fff0
- added readline alt-d and ^w support (delete till word boundaries)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
782 | int start = interface_find_previous_word(); |
693d7751fff0
- added readline alt-d and ^w support (delete till word boundaries)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
783 | |
693d7751fff0
- added readline alt-d and ^w support (delete till word boundaries)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
784 | if (start != g_cursor) |
693d7751fff0
- added readline alt-d and ^w support (delete till word boundaries)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
785 | { |
693d7751fff0
- added readline alt-d and ^w support (delete till word boundaries)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
786 | mutable_current_input().remove (start, g_cursor - start); |
693d7751fff0
- added readline alt-d and ^w support (delete till word boundaries)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
787 | g_cursor = start; |
693d7751fff0
- added readline alt-d and ^w support (delete till word boundaries)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
788 | g_needInputRender = true; |
693d7751fff0
- added readline alt-d and ^w support (delete till word boundaries)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
789 | } |
693d7751fff0
- added readline alt-d and ^w support (delete till word boundaries)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
790 | } |
693d7751fff0
- added readline alt-d and ^w support (delete till word boundaries)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
791 | break; |
693d7751fff0
- added readline alt-d and ^w support (delete till word boundaries)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
792 | |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
793 | case '\n': |
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
794 | case KEY_ENTER: |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
795 | switch (g_inputState) |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
796 | { |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
797 | case INPUTSTATE_CONFIRM_DISCONNECTION: |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
798 | break; // handled above |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
799 | |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
800 | case INPUTSTATE_ADDRESS: |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
801 | try |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
802 | { |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
803 | g_address = IPAddress::from_string (current_input()); |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
804 | } |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
805 | catch (std::exception& e) |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
806 | { |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
807 | print (e.what()); |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
808 | return; |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
809 | } |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
810 | |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
811 | if (g_address.port == 0) |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
812 | g_address.port = 10666; |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
813 | |
25
88b41eea08e0
- cleanup, refactor + better input handling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
814 | set_input_state (INPUTSTATE_PASSWORD); |
88b41eea08e0
- cleanup, refactor + better input handling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
815 | break; |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
816 | |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
817 | case INPUTSTATE_PASSWORD: |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
818 | if (g_inputState == INPUTSTATE_PASSWORD and not current_input().is_empty()) |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
819 | { |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
820 | RCONSession* session = RCONSession::new_session(); |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
821 | session->set_password (current_input()); |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
822 | session->connect (g_address); |
25
88b41eea08e0
- cleanup, refactor + better input handling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
823 | set_input_state (INPUTSTATE_NORMAL); |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
824 | } |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
825 | break; |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
826 | |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
827 | case INPUTSTATE_NORMAL: |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
828 | if (RCONSession::get_session()->send_command (current_input())) |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
829 | { |
31
b5b5a6a96d91
- added input history (use up/down to navigate)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
830 | g_input.insert (0, ""); |
24
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
831 | g_needInputRender = true; |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
832 | } |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
833 | break; |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
834 | } |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
835 | break; |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
836 | |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
837 | case 'N' - 'A' + 1: // ^N |
e651d02802c0
- the interface is now able to connect to arbitrary hosts (uses ^N to start the prompt) instead of the hardcoded localhost:10666
Teemu Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
838 | if (g_inputState == INPUTSTATE_NORMAL) |
27
089e37c0887e
- now exits cleanly with ^Q!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
839 | safe_disconnect ([]() {set_input_state (INPUTSTATE_ADDRESS);}); |
16
33bac54867bf
- added backlog scrolling
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
840 | break; |
43
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
841 | |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
842 | case '\e': // Escape |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
843 | // We may have an alt key coming |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
844 | ch = ::getch(); |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
845 | |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
846 | if (ch != ERR) |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
847 | { |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
848 | switch (ch) |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
849 | { |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
850 | case 'b': |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
851 | case 'B': |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
852 | // readline alt-b - move one word to the left |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
853 | g_cursor = interface_find_previous_word(); |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
854 | g_needInputRender = true; |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
855 | break; |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
856 | |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
857 | case 'f': |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
858 | case 'F': |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
859 | // readline alt-f - move one word to the right |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
860 | g_cursor = interface_find_next_word(); |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
861 | g_needInputRender = true; |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
862 | break; |
44
693d7751fff0
- added readline alt-d and ^w support (delete till word boundaries)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
863 | |
693d7751fff0
- added readline alt-d and ^w support (delete till word boundaries)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
864 | case 'd': |
693d7751fff0
- added readline alt-d and ^w support (delete till word boundaries)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
865 | case 'D': |
693d7751fff0
- added readline alt-d and ^w support (delete till word boundaries)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
866 | // readline alt-d - delete from here till next word boundary |
693d7751fff0
- added readline alt-d and ^w support (delete till word boundaries)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
867 | mutable_current_input().remove (g_cursor, interface_find_next_word() - g_cursor); |
693d7751fff0
- added readline alt-d and ^w support (delete till word boundaries)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
868 | g_needInputRender = true; |
693d7751fff0
- added readline alt-d and ^w support (delete till word boundaries)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
869 | break; |
43
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
870 | } |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
871 | } |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
872 | else |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
873 | { |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
874 | // No alt-key, handle pure escape |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
875 | if (g_inputState == INPUTSTATE_PASSWORD) |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
876 | set_input_state (INPUTSTATE_ADDRESS); |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
877 | else if (g_inputState == INPUTSTATE_ADDRESS) |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
878 | set_input_state (INPUTSTATE_NORMAL); |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
879 | } |
0bc07f54f522
- added readline alt-b and alt-f support (skip past words)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
880 | break; |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
881 | } |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
882 | } |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
883 | |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
884 | // ------------------------------------------------------------------------------------------------- |
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
885 | // |
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
886 | FUNCTION |
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
887 | Interface::render() -> void |
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
888 | { |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
889 | if (g_needStatusBarRender) interface_render_statusbar(); |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
890 | if (g_needInputRender) interface_render_input(); |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
891 | if (g_needOutputRender) interface_render_output(); |
47 | 892 | if (g_needNicklistRender) interface_render_nicklist(); |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
893 | |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
894 | if (g_needRefresh) |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
895 | { |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
896 | interface_position_cursor(); |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
897 | refresh(); |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
898 | g_needRefresh = false; |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
899 | } |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
900 | } |
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
901 | |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
902 | // ------------------------------------------------------------------------------------------------- |
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
903 | // |
32
ee770597a281
- added support for in-game colors
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
904 | FUNCTION print_to_console (String a) -> void |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
905 | { |
32
ee770597a281
- added support for in-game colors
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
906 | // Zandronum is retarded and SOMETIMES sends color codes as "\\c" and sometimes as "\x1C". |
ee770597a281
- added support for in-game colors
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
907 | // Let's correct that on our end and HOPE this won't cause conflicts. |
ee770597a281
- added support for in-game colors
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
908 | a.replace ("\\c", "\x1C"); |
ee770597a281
- added support for in-game colors
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
909 | |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
910 | for (char ch : a) |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
911 | { |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
912 | if (ch == '\n') |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
913 | { |
34
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
914 | g_output[g_output.size() - 1].finalize(); |
46
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
915 | g_output << ColoredLine(); |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
916 | continue; |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
917 | } |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
918 | |
34
3caf69e7350b
- added line-wrapping to the output widget: lines to output are now first compiled into renderer-friendly format. the output view then uses these pre-processed lines to determine what lines to render. Phew! What a monster of a commit.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
919 | g_output[g_output.size() - 1].add_char (ch); |
15
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
920 | } |
33da84af4bba
- log area done, re-enabled the rcon connection
Teemu Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
921 | |
17
50341dec533e
- added command sending
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
922 | g_needOutputRender = true; |
14
33b8f428bacb
- begin work on interface - input line works for the most part :)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
923 | } |
30
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
924 | |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
925 | // ------------------------------------------------------------------------------------------------- |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
926 | // |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
927 | FUNCTION |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
928 | Interface::connect (String address, String password) -> void |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
929 | { |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
930 | try |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
931 | { |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
932 | g_address = IPAddress::from_string (address); |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
933 | } |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
934 | catch (std::exception& e) |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
935 | { |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
936 | print (e.what()); |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
937 | return; |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
938 | } |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
939 | |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
940 | if (g_address.port == 0) |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
941 | g_address.port = 10666; |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
942 | |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
943 | RCONSession* session = RCONSession::new_session(); |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
944 | session->set_password (password); |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
945 | session->connect (g_address); |
21fba5183768
- added a simple command-line interface (you can now supply host and password on the command-line)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
946 | } |
47 | 947 | |
948 | // ------------------------------------------------------------------------------------------------- | |
949 | // | |
950 | FUNCTION | |
951 | Interface::set_player_names (const StringList& names) -> void | |
952 | { | |
953 | g_playerNames = names; | |
954 | g_needNicklistRender = true; | |
955 | } |