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
d302d206
Commit
d302d206
authored
Apr 19, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added toggle reminder text action;
updated SymbolsInFont when creating 'insert symbol' menu
parent
34c503c7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
11 deletions
+65
-11
src/data/action/value.cpp
src/data/action/value.cpp
+31
-2
src/data/action/value.hpp
src/data/action/value.hpp
+17
-1
src/data/symbol_font.cpp
src/data/symbol_font.cpp
+4
-0
src/gui/value/editor.hpp
src/gui/value/editor.hpp
+3
-1
src/gui/value/text.cpp
src/gui/value/text.cpp
+9
-6
src/gui/value/text.hpp
src/gui/value/text.hpp
+1
-1
No files found.
src/data/action/value.cpp
View file @
d302d206
...
...
@@ -144,8 +144,6 @@ TextValueAction* typing_action(const TextValueP& value, size_t start_i, size_t e
// no change
return
nullptr
;
}
else
{
// if (name == _("Backspace")) {
// // HACK: put start after end
if
(
reverse
)
{
return
new
TextValueAction
(
value
,
end
,
start
,
start
+
untag
(
replacement
).
size
(),
new_value
,
action_name
);
}
else
{
...
...
@@ -154,6 +152,37 @@ TextValueAction* typing_action(const TextValueP& value, size_t start_i, size_t e
}
}
// ----------------------------------------------------------------------------- : Reminder text
TextToggleReminderAction
::
TextToggleReminderAction
(
const
TextValueP
&
value
,
size_t
pos_in
)
:
ValueAction
(
value
)
{
pos
=
in_tag
(
value
->
value
(),
_
(
"<kw-"
),
pos_in
,
pos_in
);
if
(
pos
==
String
::
npos
)
{
throw
InternalError
(
_
(
"TextToggleReminderAction: not in <kw- tag"
));
}
Char
c
=
value
->
value
().
GetChar
(
pos
+
4
);
enable
=
!
(
c
==
_
(
'1'
)
||
c
==
_
(
'A'
));
// if it was not enabled, then enable it
old
=
enable
?
_
(
'1'
)
:
_
(
'0'
);
}
String
TextToggleReminderAction
::
getName
(
bool
to_undo
)
const
{
return
enable
?
_
(
"Show reminder text"
)
:
_
(
"Hide reminder text"
);
}
void
TextToggleReminderAction
::
perform
(
bool
to_undo
)
{
TextValue
&
value
=
static_cast
<
TextValue
&>
(
*
valueP
);
String
&
val
=
value
.
value
.
mutate
();
assert
(
pos
+
4
<
val
.
size
());
size_t
end
=
match_close_tag
(
val
,
pos
);
Char
&
c
=
val
[
pos
+
4
];
swap
(
c
,
old
);
if
(
end
!=
String
::
npos
&&
end
+
5
<
val
.
size
())
{
val
[
end
+
5
]
=
c
;
// </kw-c>
}
value
.
last_update
.
update
();
value
.
onAction
(
*
this
,
to_undo
);
// notify value
}
// ----------------------------------------------------------------------------- : Event
...
...
src/data/action/value.hpp
View file @
d302d206
...
...
@@ -71,13 +71,29 @@ class TextValueAction : public ValueAction {
String
name
;
};
/// Action for toggl
e
ing some formating tag on or off in some range
/// Action for toggling some formating tag on or off in some range
TextValueAction
*
toggle_format_action
(
const
TextValueP
&
value
,
const
String
&
tag
,
size_t
start_i
,
size_t
end_i
,
size_t
start
,
size_t
end
,
const
String
&
action_name
);
/// Typing in a TextValue, replace the selection [start...end) with replacement
/** start and end are cursor positions, start_i and end_i are indices*/
TextValueAction
*
typing_action
(
const
TextValueP
&
value
,
size_t
start_i
,
size_t
end_i
,
size_t
start
,
size_t
end
,
const
String
&
replacement
,
const
String
&
action_name
);
// ----------------------------------------------------------------------------- : Reminder text
/// Toggle reminder text for a keyword on or off
class
TextToggleReminderAction
:
public
ValueAction
{
public:
TextToggleReminderAction
(
const
TextValueP
&
value
,
size_t
pos
);
virtual
String
getName
(
bool
to_undo
)
const
;
virtual
void
perform
(
bool
to_undo
);
private:
size_t
pos
;
///< Position of "<kw-"
bool
enable
;
///< Should the reminder text be turned on or off?
Char
old
;
///< Old value of the <kw- tag
};
// ----------------------------------------------------------------------------- : Event
/// Notification that a script caused a value to change
...
...
src/data/symbol_font.cpp
View file @
d302d206
...
...
@@ -323,6 +323,10 @@ RealSize SymbolFont::defaultSymbolSize(Context& ctx, double font_size) {
wxMenu
*
SymbolFont
::
insertSymbolMenu
(
Context
&
ctx
)
{
if
(
!
processed_insert_symbol_menu
&&
insert_symbol_menu
)
{
// update all symbol-in-fonts
FOR_EACH_CONST
(
sym
,
symbols
)
{
sym
->
update
(
ctx
);
}
// Make menu
processed_insert_symbol_menu
=
insert_symbol_menu
->
makeMenu
(
ID_INSERT_SYMBOL_MENU_MIN
,
ctx
,
*
this
);
}
...
...
src/gui/value/editor.hpp
View file @
d302d206
...
...
@@ -13,6 +13,8 @@
#include <gui/control/card_editor.hpp>
#include <render/value/viewer.hpp>
class
IconMenu
;
// ----------------------------------------------------------------------------- : ValueEditor
/// An editor 'control' for a single value on a card
...
...
@@ -52,7 +54,7 @@ class ValueEditor {
/// a context menu is requested, add extra items to the menu m
/** return false to suppress menu */
virtual
bool
onContextMenu
(
wx
Menu
&
m
,
wxContextMenuEvent
&
ev
)
{
return
true
;
}
virtual
bool
onContextMenu
(
Icon
Menu
&
m
,
wxContextMenuEvent
&
ev
)
{
return
true
;
}
/// Get a special menu, events will be sent to onMenu
virtual
wxMenu
*
getMenu
(
int
type
)
const
{
return
nullptr
;
}
/// A menu item was selected, return true if the command was processed
...
...
src/gui/value/text.cpp
View file @
d302d206
...
...
@@ -7,6 +7,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <gui/value/text.hpp>
#include <gui/icon_menu.hpp>
#include <gui/util.hpp>
#include <data/action/value.hpp>
#include <util/tagged_string.hpp>
...
...
@@ -221,14 +222,12 @@ void TextValueEditor::onLoseFocus() {
selection_start_i
=
selection_end_i
=
0
;
}
bool
TextValueEditor
::
onContextMenu
(
wx
Menu
&
m
,
wxContextMenuEvent
&
ev
)
{
bool
TextValueEditor
::
onContextMenu
(
Icon
Menu
&
m
,
wxContextMenuEvent
&
ev
)
{
// in a keword? => "reminder text" option
size_t
kwpos
=
in_tag
(
value
().
value
(),
_
(
"<kw-"
),
selection_start_i
,
selection_start_i
);
if
(
kwpos
!=
String
::
npos
)
{
Char
c
=
String
(
value
().
value
()).
GetChar
(
kwpos
+
4
);
m
.
AppendSeparator
();
m
.
AppendCheckItem
(
ID_FORMAT_REMINDER
,
_
(
"&Reminder text"
),
_
(
"Show or hide reminder text for this keyword"
));
m
.
Check
(
ID_FORMAT_REMINDER
,
c
==
_
(
'1'
)
||
c
==
_
(
'A'
));
// reminder text currently shown
m
.
Append
(
ID_FORMAT_REMINDER
,
_
(
"reminder"
),
_MENU_
(
"reminder text"
),
_HELP_
(
"reminder text"
),
wxITEM_CHECK
);
}
// always show the menu
return
true
;
...
...
@@ -369,7 +368,7 @@ bool TextValueEditor::canFormat(int type) const {
return
!
style
().
always_symbol
&&
style
().
allow_formating
&&
style
().
symbol_font
.
valid
();
case
ID_FORMAT_REMINDER
:
return
!
style
().
always_symbol
&&
style
().
allow_formating
&&
in_tag
(
value
().
value
(),
_
(
"<kw"
),
selection_start_i
,
selection_
end
_i
)
!=
String
::
npos
;
in_tag
(
value
().
value
(),
_
(
"<kw"
),
selection_start_i
,
selection_
start
_i
)
!=
String
::
npos
;
default:
return
false
;
}
...
...
@@ -385,7 +384,7 @@ bool TextValueEditor::hasFormat(int type) const {
return
in_tag
(
value
().
value
(),
_
(
"<sym"
),
selection_start_i
,
selection_end_i
)
!=
String
::
npos
;
case
ID_FORMAT_REMINDER
:
{
const
String
&
v
=
value
().
value
();
size_t
tag
=
in_tag
(
v
,
_
(
"<kw"
),
selection_start_i
,
selection_
end
_i
);
size_t
tag
=
in_tag
(
v
,
_
(
"<kw"
),
selection_start_i
,
selection_
start
_i
);
if
(
tag
!=
String
::
npos
&&
tag
+
4
<
v
.
size
())
{
Char
c
=
v
.
GetChar
(
tag
+
4
);
return
c
==
_
(
'1'
)
||
c
==
_
(
'A'
);
...
...
@@ -411,6 +410,10 @@ void TextValueEditor::doFormat(int type) {
getSet
().
actions
.
add
(
toggle_format_action
(
valueP
(),
_
(
"sym"
),
selection_start_i
,
selection_end_i
,
selection_start
,
selection_end
,
_
(
"Symbols"
)));
break
;
}
case
ID_FORMAT_REMINDER
:
{
getSet
().
actions
.
add
(
new
TextToggleReminderAction
(
valueP
(),
selection_start_i
));
break
;
}
}
selection_start
=
ss
;
selection_end
=
se
;
...
...
src/gui/value/text.hpp
View file @
d302d206
...
...
@@ -61,7 +61,7 @@ class TextValueEditor : public TextValueViewer, public ValueEditor {
virtual
bool
onMotion
(
const
RealPoint
&
pos
,
wxMouseEvent
&
);
virtual
bool
onMouseWheel
(
const
RealPoint
&
pos
,
wxMouseEvent
&
ev
);
virtual
bool
onContextMenu
(
wx
Menu
&
m
,
wxContextMenuEvent
&
);
virtual
bool
onContextMenu
(
Icon
Menu
&
m
,
wxContextMenuEvent
&
);
virtual
wxMenu
*
getMenu
(
int
type
)
const
;
virtual
bool
onCommand
(
int
);
...
...
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