Wed, 20 Jul 2016 15:01:26 +0300
Reformatted parentheses in interface.cpp.
46
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
109 | 2 | Copyright 2014 - 2016 Teemu Piippo |
46
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | All rights reserved. |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | Redistribution and use in source and binary forms, with or without |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | modification, are permitted provided that the following conditions |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | are met: |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | 1. Redistributions of source code must retain the above copyright |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | notice, this list of conditions and the following disclaimer. |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | 2. Redistributions in binary form must reproduce the above copyright |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | notice, this list of conditions and the following disclaimer in the |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | documentation and/or other materials provided with the distribution. |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | 3. Neither the name of the copyright holder nor the names of its |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | contributors may be used to endorse or promote products derived from |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | this software without specific prior written permission. |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | */ |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | #pragma once |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | #include "main.h" |
88
08ccaf26cffd
Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents:
73
diff
changeset
|
33 | BEGIN_ZFC_NAMESPACE |
46
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | |
89
777b2a10b835
Add support for standard pdcurses, thanks to Leonard for pointing out the solutions to a few mysteries.
Teemu Piippo <tsapii@utu.fi>
parents:
88
diff
changeset
|
35 | // The order of these colors appears to differ between curses distributions (PDCurses and its |
777b2a10b835
Add support for standard pdcurses, thanks to Leonard for pointing out the solutions to a few mysteries.
Teemu Piippo <tsapii@utu.fi>
parents:
88
diff
changeset
|
36 | // win32a for instance have blue and red swapped). So we need to explicitly define the values |
777b2a10b835
Add support for standard pdcurses, thanks to Leonard for pointing out the solutions to a few mysteries.
Teemu Piippo <tsapii@utu.fi>
parents:
88
diff
changeset
|
37 | // of the enumerators based on their curses values. |
777b2a10b835
Add support for standard pdcurses, thanks to Leonard for pointing out the solutions to a few mysteries.
Teemu Piippo <tsapii@utu.fi>
parents:
88
diff
changeset
|
38 | enum Color |
777b2a10b835
Add support for standard pdcurses, thanks to Leonard for pointing out the solutions to a few mysteries.
Teemu Piippo <tsapii@utu.fi>
parents:
88
diff
changeset
|
39 | { |
100
d301ead29d7c
Apply Leonard's patch for fixing the colors:
Teemu Piippo <tsapii@utu.fi>
parents:
89
diff
changeset
|
40 | BLACK = COLOR_BLACK, |
d301ead29d7c
Apply Leonard's patch for fixing the colors:
Teemu Piippo <tsapii@utu.fi>
parents:
89
diff
changeset
|
41 | RED = COLOR_RED, |
d301ead29d7c
Apply Leonard's patch for fixing the colors:
Teemu Piippo <tsapii@utu.fi>
parents:
89
diff
changeset
|
42 | GREEN = COLOR_GREEN, |
d301ead29d7c
Apply Leonard's patch for fixing the colors:
Teemu Piippo <tsapii@utu.fi>
parents:
89
diff
changeset
|
43 | YELLOW = COLOR_YELLOW, |
d301ead29d7c
Apply Leonard's patch for fixing the colors:
Teemu Piippo <tsapii@utu.fi>
parents:
89
diff
changeset
|
44 | BLUE = COLOR_BLUE, |
d301ead29d7c
Apply Leonard's patch for fixing the colors:
Teemu Piippo <tsapii@utu.fi>
parents:
89
diff
changeset
|
45 | MAGENTA = COLOR_MAGENTA, |
d301ead29d7c
Apply Leonard's patch for fixing the colors:
Teemu Piippo <tsapii@utu.fi>
parents:
89
diff
changeset
|
46 | CYAN = COLOR_CYAN, |
d301ead29d7c
Apply Leonard's patch for fixing the colors:
Teemu Piippo <tsapii@utu.fi>
parents:
89
diff
changeset
|
47 | WHITE = COLOR_WHITE, |
d301ead29d7c
Apply Leonard's patch for fixing the colors:
Teemu Piippo <tsapii@utu.fi>
parents:
89
diff
changeset
|
48 | DEFAULT = 8, |
89
777b2a10b835
Add support for standard pdcurses, thanks to Leonard for pointing out the solutions to a few mysteries.
Teemu Piippo <tsapii@utu.fi>
parents:
88
diff
changeset
|
49 | NUM_COLORS |
777b2a10b835
Add support for standard pdcurses, thanks to Leonard for pointing out the solutions to a few mysteries.
Teemu Piippo <tsapii@utu.fi>
parents:
88
diff
changeset
|
50 | }; |
777b2a10b835
Add support for standard pdcurses, thanks to Leonard for pointing out the solutions to a few mysteries.
Teemu Piippo <tsapii@utu.fi>
parents:
88
diff
changeset
|
51 | |
60 | 52 | // ------------------------------------------------------------------------------------------------- |
53 | // | |
46
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | enum |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | { |
100
d301ead29d7c
Apply Leonard's patch for fixing the colors:
Teemu Piippo <tsapii@utu.fi>
parents:
89
diff
changeset
|
56 | RLINE_ON_COLOR = 256, |
d301ead29d7c
Apply Leonard's patch for fixing the colors:
Teemu Piippo <tsapii@utu.fi>
parents:
89
diff
changeset
|
57 | RLINE_OFF_COLOR = 264, |
d301ead29d7c
Apply Leonard's patch for fixing the colors:
Teemu Piippo <tsapii@utu.fi>
parents:
89
diff
changeset
|
58 | RLINE_ON_BOLD = 272, |
d301ead29d7c
Apply Leonard's patch for fixing the colors:
Teemu Piippo <tsapii@utu.fi>
parents:
89
diff
changeset
|
59 | RLINE_OFF_BOLD |
46
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | }; |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | |
60 | 62 | // ------------------------------------------------------------------------------------------------- |
63 | // | |
46
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | class ColoredLine |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | { |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | public: |
88
08ccaf26cffd
Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents:
73
diff
changeset
|
67 | ColoredLine(); |
46
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | |
69
eb4c25284a19
Removed a lot of boilerplate code
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
69 | const Vector<int>& data() const { return m_data; } |
eb4c25284a19
Removed a lot of boilerplate code
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
70 | int length() const { return m_length; } |
eb4c25284a19
Removed a lot of boilerplate code
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
71 | void add_char (char ch); |
132
8a4690db252e
Added support for colored nicknames
Teemu Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
72 | void add_string (const String& msg); |
69
eb4c25284a19
Removed a lot of boilerplate code
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
73 | void finalize(); |
eb4c25284a19
Removed a lot of boilerplate code
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
74 | int rows (int cols) const; |
46
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
75 | |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
76 | private: |
113
b3a33bc2e482
Added support for long-form color codes, such as \c[Green]
Teemu Piippo <crimsondusk64@gmail.com>
parents:
109
diff
changeset
|
77 | void activate_color (Color color, bool bold); |
69
eb4c25284a19
Removed a lot of boilerplate code
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
78 | void set_color (Color a, bool on); |
46
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
79 | |
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | Vector<int> m_data; |
88
08ccaf26cffd
Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents:
73
diff
changeset
|
81 | int m_length; |
08ccaf26cffd
Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents:
73
diff
changeset
|
82 | bool m_final; |
08ccaf26cffd
Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents:
73
diff
changeset
|
83 | Color m_activeColor; |
08ccaf26cffd
Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents:
73
diff
changeset
|
84 | bool m_boldActive; |
08ccaf26cffd
Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents:
73
diff
changeset
|
85 | int m_colorCodeStage; |
46
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | String m_string; |
113
b3a33bc2e482
Added support for long-form color codes, such as \c[Green]
Teemu Piippo <crimsondusk64@gmail.com>
parents:
109
diff
changeset
|
87 | String m_incomingColorName; |
46
19be47c9bab7
- renamed RendererLine to ColoredLine and split it into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
88 | }; |
88
08ccaf26cffd
Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents:
73
diff
changeset
|
89 | |
08ccaf26cffd
Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents:
73
diff
changeset
|
90 | END_ZFC_NAMESPACE |