Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
d3b19a0b
Commit
d3b19a0b
authored
May 14, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slightly nicer syntax highlighting
parent
368d5150
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
68 additions
and
35 deletions
+68
-35
src/data/action/keyword.cpp
src/data/action/keyword.cpp
+13
-9
src/data/export_template.hpp
src/data/export_template.hpp
+6
-0
src/data/font.cpp
src/data/font.cpp
+22
-14
src/data/font.hpp
src/data/font.hpp
+15
-7
src/gui/html_export_window.cpp
src/gui/html_export_window.cpp
+1
-0
src/gui/html_export_window.hpp
src/gui/html_export_window.hpp
+0
-1
src/render/text/element.cpp
src/render/text/element.cpp
+11
-4
No files found.
src/data/action/keyword.cpp
View file @
d3b19a0b
...
@@ -95,8 +95,8 @@ void KeywordReminderTextValue::highlight(const String& code, const vector<Script
...
@@ -95,8 +95,8 @@ void KeywordReminderTextValue::highlight(const String& code, const vector<Script
// becomes:
// becomes:
// bla <code>{<code-kw>if</code-kw> code "<code-string>x</code-string>" } bla
// bla <code>{<code-kw>if</code-kw> code "<code-string>x</code-string>" } bla
String
new_value
;
String
new_value
;
int
in_brace
=
0
;
vector
<
int
>
in_brace
;
// types of braces we are in, 0 for code brace, 1 for string escapes
bool
in_string
=
true
;
bool
in_string
=
true
;
vector
<
ScriptParseError
>::
const_iterator
error
=
errors
.
begin
();
vector
<
ScriptParseError
>::
const_iterator
error
=
errors
.
begin
();
for
(
size_t
pos
=
0
;
pos
<
code
.
size
()
;
)
{
for
(
size_t
pos
=
0
;
pos
<
code
.
size
()
;
)
{
// error underlining
// error underlining
...
@@ -120,26 +120,30 @@ void KeywordReminderTextValue::highlight(const String& code, const vector<Script
...
@@ -120,26 +120,30 @@ void KeywordReminderTextValue::highlight(const String& code, const vector<Script
new_value
+=
_
(
'\1'
);
// escape
new_value
+=
_
(
'\1'
);
// escape
++
pos
;
++
pos
;
}
else
if
(
c
==
_
(
'{'
))
{
}
else
if
(
c
==
_
(
'{'
))
{
in_brace
++
;
if
(
in_string
)
{
if
(
in_brace
==
1
)
new_value
+=
_
(
"<code>"
);
new_value
+=
_
(
"<code>"
);
if
(
in_string
)
in_string
=
false
;
in_brace
.
push_back
(
1
);
in_string
=
false
;
}
else
{
in_brace
.
push_back
(
0
);
}
new_value
+=
c
;
new_value
+=
c
;
++
pos
;
++
pos
;
}
else
if
(
c
==
_
(
'}'
)
&&
!
in_string
)
{
}
else
if
(
c
==
_
(
'}'
)
&&
!
in_string
)
{
new_value
+=
c
;
new_value
+=
c
;
in_brace
--
;
if
(
!
in_brace
.
empty
()
&&
in_brace
.
back
()
==
1
)
{
if
(
in_brace
==
0
)
{
new_value
+=
_
(
"</code>"
);
new_value
+=
_
(
"</code>"
);
in_string
=
true
;
in_string
=
true
;
}
}
if
(
!
in_brace
.
empty
())
in_brace
.
pop_back
();
++
pos
;
++
pos
;
}
else
if
(
c
==
_
(
'"'
))
{
}
else
if
(
c
==
_
(
'"'
))
{
if
(
in_string
)
{
if
(
in_string
)
{
in_string
=
false
;
in_string
=
false
;
new_value
+=
_
(
"
\"
<
code-str
>"
);
new_value
+=
_
(
"
\"
<
/code-str><code
>"
);
}
else
{
}
else
{
in_string
=
true
;
in_string
=
true
;
new_value
+=
_
(
"<code-str>
\"
"
);
new_value
+=
_
(
"<
/code><
code-str>
\"
"
);
}
}
++
pos
;
++
pos
;
}
else
if
(
c
==
_
(
'\\'
)
&&
in_string
&&
pos
+
1
<
code
.
size
())
{
}
else
if
(
c
==
_
(
'\\'
)
&&
in_string
&&
pos
+
1
<
code
.
size
())
{
...
...
src/data/export_template.hpp
View file @
d3b19a0b
...
@@ -30,5 +30,11 @@ class ExportTemplate : public Packaged {
...
@@ -30,5 +30,11 @@ class ExportTemplate : public Packaged {
DECLARE_REFLECTION
();
DECLARE_REFLECTION
();
};
};
// ----------------------------------------------------------------------------- : ExportPackage
/// A package that is being written to when exporting
class
ExportingPackage
:
public
Package
{
};
// ----------------------------------------------------------------------------- : EOF
// ----------------------------------------------------------------------------- : EOF
#endif
#endif
src/data/font.cpp
View file @
d3b19a0b
...
@@ -14,11 +14,10 @@ Font::Font()
...
@@ -14,11 +14,10 @@ Font::Font()
:
name
()
:
name
()
,
size
(
1
)
,
size
(
1
)
,
underline
(
false
)
,
underline
(
false
)
,
weight_i
(
wxFONTWEIGHT_NORMAL
),
style_i
(
wxFONTSTYLE_NORMAL
)
,
scale_down_to
(
100000
)
,
scale_down_to
(
100000
)
,
shadow_displacement
(
0
,
0
)
,
shadow_displacement
(
0
,
0
)
,
separator_color
(
128
,
128
,
128
)
,
separator_color
(
128
,
128
,
128
)
,
type
(
NORMAL
)
,
flags
(
FONT_
NORMAL
)
{}
{}
bool
Font
::
update
(
Context
&
ctx
)
{
bool
Font
::
update
(
Context
&
ctx
)
{
...
@@ -31,8 +30,9 @@ bool Font::update(Context& ctx) {
...
@@ -31,8 +30,9 @@ bool Font::update(Context& ctx) {
|
underline
.
update
(
ctx
)
|
underline
.
update
(
ctx
)
|
color
.
update
(
ctx
)
|
color
.
update
(
ctx
)
|
shadow_color
.
update
(
ctx
);
|
shadow_color
.
update
(
ctx
);
weight_i
=
weight
()
==
_
(
"bold"
)
?
wxBOLD
:
wxNORMAL
;
flags
=
flags
&
(
~
FONT_BOLD
&
~
FONT_ITALIC
)
style_i
=
style
()
==
_
(
"italic"
)
?
wxITALIC
:
wxNORMAL
;
|
(
weight
()
==
_
(
"bold"
)
?
FONT_BOLD
:
FONT_NORMAL
)
|
(
style
()
==
_
(
"italic"
)
?
FONT_ITALIC
:
FONT_NORMAL
);
return
changes
;
return
changes
;
}
}
void
Font
::
initDependencies
(
Context
&
ctx
,
const
Dependency
&
dep
)
const
{
void
Font
::
initDependencies
(
Context
&
ctx
,
const
Dependency
&
dep
)
const
{
...
@@ -46,15 +46,20 @@ void Font::initDependencies(Context& ctx, const Dependency& dep) const {
...
@@ -46,15 +46,20 @@ void Font::initDependencies(Context& ctx, const Dependency& dep) const {
shadow_color
.
initDependencies
(
ctx
,
dep
);
shadow_color
.
initDependencies
(
ctx
,
dep
);
}
}
FontP
Font
::
make
(
bool
bold
,
bool
italic
,
bool
placeholder_color
,
bool
code_color
,
Color
*
other_color
)
const
{
FontP
Font
::
make
(
int
add_flags
,
Color
*
other_color
)
const
{
FontP
f
(
new
Font
(
*
this
));
FontP
f
(
new
Font
(
*
this
));
if
(
bold
)
f
->
weight_i
=
wxFONTWEIGHT_BOLD
;
f
->
flags
|=
add_flags
;
if
(
italic
)
f
->
style_i
=
wxFONTSTYLE_ITALIC
;
if
(
add_flags
&
FONT_CODE_STRING
)
{
if
(
code_color
)
{
f
->
color
=
Color
(
0
,
0
,
100
);
}
if
(
add_flags
&
FONT_CODE
)
{
f
->
color
=
Color
(
128
,
0
,
0
);
f
->
color
=
Color
(
128
,
0
,
0
);
f
->
type
=
TYPEWRITER
;
}
}
if
(
placeholder_color
)
{
if
(
add_flags
&
FONT_CODE_KW
)
{
f
->
color
=
Color
(
158
,
0
,
0
);
f
->
flags
|=
FONT_BOLD
;
}
if
(
add_flags
&
FONT_SOFT
)
{
f
->
color
=
f
->
separator_color
;
f
->
color
=
f
->
separator_color
;
f
->
shadow_displacement
=
RealSize
(
0
,
0
);
// no shadow
f
->
shadow_displacement
=
RealSize
(
0
,
0
);
// no shadow
}
}
...
@@ -66,13 +71,16 @@ FontP Font::make(bool bold, bool italic, bool placeholder_color, bool code_color
...
@@ -66,13 +71,16 @@ FontP Font::make(bool bold, bool italic, bool placeholder_color, bool code_color
wxFont
Font
::
toWxFont
(
double
scale
)
const
{
wxFont
Font
::
toWxFont
(
double
scale
)
const
{
int
size_i
=
scale
*
size
;
int
size_i
=
scale
*
size
;
if
(
name
().
empty
())
{
int
weight_i
=
flags
&
FONT_BOLD
?
wxFONTWEIGHT_BOLD
:
wxFONTWEIGHT_NORMAL
;
int
style_i
=
flags
&
FONT_ITALIC
?
wxFONTSTYLE_ITALIC
:
wxFONTSTYLE_NORMAL
;
if
(
flags
&
FONT_CODE
)
{
if
(
size_i
<
2
)
size_i
=
wxNORMAL_FONT
->
GetPointSize
();
return
wxFont
(
size_i
,
wxFONTFAMILY_TELETYPE
,
wxFONTSTYLE_NORMAL
,
weight_i
,
underline
(),
_
(
"Courier New"
));
}
else
if
(
name
().
empty
())
{
wxFont
font
=
*
wxNORMAL_FONT
;
wxFont
font
=
*
wxNORMAL_FONT
;
font
.
SetPointSize
(
size
>
1
?
size_i
:
scale
*
font
.
GetPointSize
());
font
.
SetPointSize
(
size
>
1
?
size_i
:
scale
*
font
.
GetPointSize
());
return
font
;
return
font
;
}
else
if
(
type
==
TYPEWRITER
)
{
}
else
if
(
flags
&
FONT_ITALIC
&&
!
italic_name
().
empty
())
{
return
wxFont
(
size_i
,
wxFONTFAMILY_TELETYPE
,
weight_i
,
underline
(),
_
(
"Courier New"
));
}
else
if
(
style_i
==
wxFONTSTYLE_ITALIC
&&
!
italic_name
().
empty
())
{
return
wxFont
(
size_i
,
wxFONTFAMILY_DEFAULT
,
wxFONTSTYLE_NORMAL
,
weight_i
,
underline
(),
italic_name
());
return
wxFont
(
size_i
,
wxFONTFAMILY_DEFAULT
,
wxFONTSTYLE_NORMAL
,
weight_i
,
underline
(),
italic_name
());
}
else
{
}
else
{
return
wxFont
(
size_i
,
wxFONTFAMILY_DEFAULT
,
style_i
,
weight_i
,
underline
(),
name
());
return
wxFont
(
size_i
,
wxFONTFAMILY_DEFAULT
,
style_i
,
weight_i
,
underline
(),
name
());
...
...
src/data/font.hpp
View file @
d3b19a0b
...
@@ -17,6 +17,18 @@ DECLARE_POINTER_TYPE(Font);
...
@@ -17,6 +17,18 @@ DECLARE_POINTER_TYPE(Font);
// ----------------------------------------------------------------------------- : Font
// ----------------------------------------------------------------------------- : Font
enum
FontFlags
{
FONT_NORMAL
=
0
,
FONT_BOLD
=
0x01
,
FONT_ITALIC
=
0x02
,
FONT_SOFT
=
0x04
,
FONT_CODE
=
0x08
,
FONT_CODE_KW
=
0x10
// syntax highlighting
,
FONT_CODE_STRING
=
0x20
// syntax highlighting
,
FONT_CODE_NUMBER
=
0x40
// syntax highlighting
,
FONT_CODE_OPER
=
0x80
// syntax highlighting
};
/// A font for rendering text
/// A font for rendering text
/** Contains additional information about scaling, color and shadow */
/** Contains additional information about scaling, color and shadow */
class
Font
:
public
IntrusivePtrBase
<
Font
>
{
class
Font
:
public
IntrusivePtrBase
<
Font
>
{
...
@@ -26,16 +38,12 @@ class Font : public IntrusivePtrBase<Font> {
...
@@ -26,16 +38,12 @@ class Font : public IntrusivePtrBase<Font> {
Scriptable
<
double
>
size
;
///< Size of the font
Scriptable
<
double
>
size
;
///< Size of the font
Scriptable
<
String
>
weight
,
style
;
///< Weight and style of the font (bold/italic)
Scriptable
<
String
>
weight
,
style
;
///< Weight and style of the font (bold/italic)
Scriptable
<
bool
>
underline
;
///< Underlined?
Scriptable
<
bool
>
underline
;
///< Underlined?
int
weight_i
,
style_i
;
///< wx constants for weight and style
double
scale_down_to
;
///< Smallest size to scale down to
double
scale_down_to
;
///< Smallest size to scale down to
Scriptable
<
Color
>
color
;
///< Color to use
Scriptable
<
Color
>
color
;
///< Color to use
Scriptable
<
Color
>
shadow_color
;
///< Color for shadow
Scriptable
<
Color
>
shadow_color
;
///< Color for shadow
RealSize
shadow_displacement
;
///< Position of the shadow
RealSize
shadow_displacement
;
///< Position of the shadow
Color
separator_color
;
///< Color for <sep> text
Color
separator_color
;
///< Color for <sep> text
enum
{
int
flags
;
///< FontFlags for this font
NORMAL
,
TYPEWRITER
,
///< Use a typewriter font
}
type
;
Font
();
Font
();
...
@@ -47,8 +55,8 @@ class Font : public IntrusivePtrBase<Font> {
...
@@ -47,8 +55,8 @@ class Font : public IntrusivePtrBase<Font> {
/// Does this font have a shadow?
/// Does this font have a shadow?
inline
bool
hasShadow
()
{
return
shadow_displacement
.
width
!=
0
||
shadow_displacement
.
height
!=
0
;
}
inline
bool
hasShadow
()
{
return
shadow_displacement
.
width
!=
0
||
shadow_displacement
.
height
!=
0
;
}
///
Make a bold/italic/placeholder version of this font
///
Add style to a font, and optionally change the color
FontP
make
(
bool
bold
,
bool
italic
,
bool
placeholder_color
,
bool
code_color
,
Color
*
other_color
)
const
;
FontP
make
(
int
add_flags
,
Color
*
other_color
)
const
;
/// Convert this font to a wxFont
/// Convert this font to a wxFont
wxFont
toWxFont
(
double
scale
)
const
;
wxFont
toWxFont
(
double
scale
)
const
;
...
...
src/gui/html_export_window.cpp
View file @
d3b19a0b
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
#include <gui/html_export_window.hpp>
#include <gui/html_export_window.hpp>
#include <gui/control/package_list.hpp>
#include <gui/control/package_list.hpp>
#include <data/export_template.hpp>
#include <util/error.hpp>
#include <util/error.hpp>
// ----------------------------------------------------------------------------- : HtmlExportWindow
// ----------------------------------------------------------------------------- : HtmlExportWindow
...
...
src/gui/html_export_window.hpp
View file @
d3b19a0b
...
@@ -10,7 +10,6 @@
...
@@ -10,7 +10,6 @@
// ----------------------------------------------------------------------------- : Includes
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <util/prec.hpp>
#include <data/export_template.hpp>
class
PackageList
;
class
PackageList
;
DECLARE_POINTER_TYPE
(
Set
);
DECLARE_POINTER_TYPE
(
Set
);
...
...
src/render/text/element.cpp
View file @
d3b19a0b
...
@@ -160,10 +160,17 @@ struct TextElementsFromString {
...
@@ -160,10 +160,17 @@ struct TextElementsFromString {
e
=
new
SymbolTextElement
(
text
,
pos
,
pos
+
1
,
style
.
symbol_font
,
&
ctx
);
e
=
new
SymbolTextElement
(
text
,
pos
,
pos
+
1
,
style
.
symbol_font
,
&
ctx
);
bracket
=
false
;
bracket
=
false
;
}
else
{
}
else
{
FontP
font
=
style
.
font
.
make
(
bold
>
0
,
italic
>
0
,
soft
>
0
||
kwpph
>
0
,
code
>
0
,
FontP
font
=
style
.
font
.
make
(
param
>
0
||
param_ref
>
0
(
bold
>
0
?
FONT_BOLD
:
FONT_NORMAL
)
|
?
&
param_colors
[(
param_id
++
)
%
param_colors_count
]
(
italic
>
0
?
FONT_ITALIC
:
FONT_NORMAL
)
|
:
nullptr
);
(
soft
>
0
?
FONT_SOFT
:
FONT_NORMAL
)
|
(
kwpph
>
0
?
FONT_SOFT
:
FONT_NORMAL
)
|
(
code
>
0
?
FONT_CODE
:
FONT_NORMAL
)
|
(
code_kw
>
0
?
FONT_CODE_KW
:
FONT_NORMAL
)
|
(
code_string
>
0
?
FONT_CODE_STRING
:
FONT_NORMAL
),
param
>
0
||
param_ref
>
0
?
&
param_colors
[(
param_id
++
)
%
param_colors_count
]
:
nullptr
);
bracket
=
kwpph
>
0
||
param
>
0
;
bracket
=
kwpph
>
0
||
param
>
0
;
e
=
new
FontTextElement
(
e
=
new
FontTextElement
(
text
,
text
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment