Skip to content

Commit 35a09ae

Browse files
committed
In the beginning...
0 parents  commit 35a09ae

File tree

217 files changed

+56879
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

217 files changed

+56879
-0
lines changed

.clang-format

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
BasedOnStyle: LLVM
3+
AccessModifierOffset: -4
4+
AlignAfterOpenBracket: DontAlign
5+
AlignConsecutiveAssignments: false
6+
AlignConsecutiveDeclarations: false
7+
AlignEscapedNewlines: DontAlign
8+
AlignOperands: false
9+
AlignTrailingComments: false
10+
AllowAllParametersOfDeclarationOnNextLine: false
11+
AllowShortBlocksOnASingleLine: false
12+
AllowShortCaseLabelsOnASingleLine: true
13+
AllowShortFunctionsOnASingleLine: InlineOnly
14+
AllowShortIfStatementsOnASingleLine: false
15+
AllowShortLoopsOnASingleLine: false
16+
AlwaysBreakAfterDefinitionReturnType: None
17+
AlwaysBreakAfterReturnType: None
18+
AlwaysBreakBeforeMultilineStrings: false
19+
AlwaysBreakTemplateDeclarations: Yes
20+
BinPackArguments: false
21+
BinPackParameters: false
22+
BraceWrapping:
23+
AfterClass: true
24+
AfterControlStatement: true
25+
AfterEnum: true
26+
AfterFunction: true
27+
AfterNamespace: true
28+
AfterStruct: true
29+
AfterUnion: true
30+
AfterCaseLabel: true
31+
AfterExternBlock: true
32+
BeforeCatch: true
33+
BeforeElse: true
34+
IndentBraces: false
35+
SplitEmptyFunction: false
36+
SplitEmptyRecord: true
37+
SplitEmptyNamespace: true
38+
BreakBeforeBinaryOperators: None
39+
BreakBeforeBraces: Custom
40+
BreakBeforeTernaryOperators: true
41+
BreakConstructorInitializers: BeforeColon
42+
BreakInheritanceList: BeforeColon
43+
BreakStringLiterals: true
44+
ColumnLimit: 100
45+
CompactNamespaces: false
46+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
47+
ConstructorInitializerIndentWidth: 4
48+
ContinuationIndentWidth: 4
49+
Cpp11BracedListStyle: true
50+
DerivePointerAlignment: false
51+
DisableFormat: false
52+
ExperimentalAutoDetectBinPacking: false
53+
FixNamespaceComments: true
54+
IncludeBlocks: Preserve
55+
IndentCaseLabels: true
56+
IndentPPDirectives: None
57+
IndentWidth: 4
58+
IndentWrappedFunctionNames: true
59+
KeepEmptyLinesAtTheStartOfBlocks: false
60+
NamespaceIndentation: None
61+
PointerAlignment: Left
62+
ReflowComments: false
63+
SortIncludes: false
64+
SortUsingDeclarations: false
65+
SpaceAfterCStyleCast: true
66+
SpaceAfterTemplateKeyword: false
67+
SpaceBeforeAssignmentOperators: true
68+
SpaceBeforeCpp11BracedList: false
69+
SpaceBeforeCtorInitializerColon: true
70+
SpaceBeforeInheritanceColon: false
71+
SpaceBeforeParens: Never
72+
SpaceBeforeRangeBasedForLoopColon: true
73+
SpaceInEmptyParentheses: false
74+
SpacesBeforeTrailingComments: 1
75+
SpacesInAngles: false
76+
SpacesInCStyleCastParentheses: false
77+
SpacesInContainerLiterals: true
78+
SpacesInParentheses: false
79+
SpacesInSquareBrackets: false
80+
Standard: Cpp11
81+
TabWidth: 4
82+
UseTab: Never

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build/
2+
*.user
3+
*.user.*

COPYING

Lines changed: 346 additions & 0 deletions
Large diffs are not rendered by default.

COPYING.LIB

Lines changed: 481 additions & 0 deletions
Large diffs are not rendered by default.

Character.h

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
/*
2+
This file is part of terminal, KDE's terminal.
3+
4+
Copyright 2007-2008 by Robert Knight <[email protected]>
5+
Copyright 1997,1998 by Lars Doelle <[email protected]>
6+
7+
This program is free software; you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License as published by
9+
the Free Software Foundation; either version 2 of the License, or
10+
(at your option) any later version.
11+
12+
This program is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with this program; if not, write to the Free Software
19+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20+
02110-1301 USA.
21+
*/
22+
23+
#ifndef CHARACTER_H
24+
#define CHARACTER_H
25+
26+
// terminal
27+
#include "CharacterColor.h"
28+
#include "CharacterWidth.h"
29+
30+
// Qt
31+
#include <QVector>
32+
33+
namespace terminal {
34+
typedef unsigned char LineProperty;
35+
36+
typedef quint16 RenditionFlags;
37+
38+
const int LINE_DEFAULT = 0;
39+
const int LINE_WRAPPED = (1 << 0);
40+
const int LINE_DOUBLEWIDTH = (1 << 1);
41+
const int LINE_DOUBLEHEIGHT = (1 << 2);
42+
43+
const RenditionFlags DEFAULT_RENDITION = 0;
44+
const RenditionFlags RE_BOLD = (1 << 0);
45+
const RenditionFlags RE_BLINK = (1 << 1);
46+
const RenditionFlags RE_UNDERLINE = (1 << 2);
47+
const RenditionFlags RE_REVERSE = (1 << 3); // Screen only
48+
const RenditionFlags RE_ITALIC = (1 << 4);
49+
const RenditionFlags RE_CURSOR = (1 << 5);
50+
const RenditionFlags RE_EXTENDED_CHAR = (1 << 6);
51+
const RenditionFlags RE_FAINT = (1 << 7);
52+
const RenditionFlags RE_STRIKEOUT = (1 << 8);
53+
const RenditionFlags RE_CONCEAL = (1 << 9);
54+
const RenditionFlags RE_OVERLINE = (1 << 10);
55+
56+
/**
57+
* A single character in the terminal which consists of a unicode character
58+
* value, foreground and background colors and a set of rendition attributes
59+
* which specify how it should be drawn.
60+
*/
61+
class Character
62+
{
63+
public:
64+
/**
65+
* Constructs a new character.
66+
*
67+
* @param _c The unicode character value of this character.
68+
* @param _f The foreground color used to draw the character.
69+
* @param _b The color used to draw the character's background.
70+
* @param _r A set of rendition flags which specify how this character
71+
* is to be drawn.
72+
* @param _real Indicate whether this character really exists, or exists
73+
* simply as place holder.
74+
*/
75+
explicit inline Character(uint _c = ' ',
76+
CharacterColor _f = CharacterColor(COLOR_SPACE_DEFAULT, DEFAULT_FORE_COLOR),
77+
CharacterColor _b = CharacterColor(COLOR_SPACE_DEFAULT, DEFAULT_BACK_COLOR),
78+
RenditionFlags _r = DEFAULT_RENDITION,
79+
bool _real = true)
80+
: character(_c)
81+
, rendition(_r)
82+
, foregroundColor(_f)
83+
, backgroundColor(_b)
84+
, isRealCharacter(_real) { }
85+
86+
/** The unicode character value for this character.
87+
*
88+
* if RE_EXTENDED_CHAR is set, character is a hash code which can be used to
89+
* look up the unicode character sequence in the ExtendedCharTable used to
90+
* create the sequence.
91+
*/
92+
uint character;
93+
94+
/** A combination of RENDITION flags which specify options for drawing the character. */
95+
RenditionFlags rendition;
96+
97+
/** The foreground color used to draw this character. */
98+
CharacterColor foregroundColor;
99+
100+
/** The color used to draw this character's background. */
101+
CharacterColor backgroundColor;
102+
103+
/** Indicate whether this character really exists, or exists simply as place holder.
104+
*
105+
* TODO: this boolean filed can be further improved to become a enum filed, which
106+
* indicates different roles:
107+
*
108+
* RealCharacter: a character which really exists
109+
* PlaceHolderCharacter: a character which exists as place holder
110+
* TabStopCharacter: a special place holder for HT("\t")
111+
*/
112+
bool isRealCharacter;
113+
114+
/**
115+
* returns true if the format (color, rendition flag) of the compared characters is equal
116+
*/
117+
bool equalsFormat(const Character &other) const;
118+
119+
/**
120+
* Compares two characters and returns true if they have the same unicode character value,
121+
* rendition and colors.
122+
*/
123+
friend bool operator ==(const Character &a, const Character &b);
124+
125+
/**
126+
* Compares two characters and returns true if they have different unicode character values,
127+
* renditions or colors.
128+
*/
129+
friend bool operator !=(const Character &a, const Character &b);
130+
131+
inline bool isSpace() const
132+
{
133+
if (rendition & RE_EXTENDED_CHAR) {
134+
return false;
135+
} else {
136+
return QChar(character).isSpace();
137+
}
138+
}
139+
140+
inline int width() const {
141+
return width(character);
142+
}
143+
144+
static int width(uint ucs4) {
145+
return characterWidth(ucs4);
146+
}
147+
148+
static int stringWidth(const uint *ucs4Str, int len) {
149+
int w = 0;
150+
for (int i = 0; i < len; ++i) {
151+
w += width(ucs4Str[i]);
152+
}
153+
return w;
154+
}
155+
156+
inline static int stringWidth(const QString &str) {
157+
QVector<uint> ucs4Str = str.toUcs4();
158+
return stringWidth(ucs4Str.constData(), ucs4Str.length());
159+
}
160+
};
161+
162+
inline bool operator ==(const Character &a, const Character &b)
163+
{
164+
return a.character == b.character && a.equalsFormat(b);
165+
}
166+
167+
inline bool operator !=(const Character &a, const Character &b)
168+
{
169+
return !operator==(a, b);
170+
}
171+
172+
inline bool Character::equalsFormat(const Character &other) const
173+
{
174+
return backgroundColor == other.backgroundColor
175+
&& foregroundColor == other.foregroundColor
176+
&& rendition == other.rendition;
177+
}
178+
}
179+
Q_DECLARE_TYPEINFO(terminal::Character, Q_MOVABLE_TYPE);
180+
181+
#endif // CHARACTER_H

0 commit comments

Comments
 (0)