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
60441224
Commit
60441224
authored
Apr 21, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
"insert parameter" and "user parameter" buttons now work.
parent
2ad7d0d9
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
102 additions
and
42 deletions
+102
-42
src/data/keyword.hpp
src/data/keyword.hpp
+0
-2
src/gui/control/card_editor.cpp
src/gui/control/card_editor.cpp
+4
-0
src/gui/control/card_editor.hpp
src/gui/control/card_editor.hpp
+5
-0
src/gui/control/text_ctrl.cpp
src/gui/control/text_ctrl.cpp
+3
-0
src/gui/set/keywords_panel.cpp
src/gui/set/keywords_panel.cpp
+39
-21
src/gui/set/keywords_panel.hpp
src/gui/set/keywords_panel.hpp
+3
-0
src/gui/value/editor.hpp
src/gui/value/editor.hpp
+6
-3
src/gui/value/text.cpp
src/gui/value/text.cpp
+5
-2
src/gui/value/text.hpp
src/gui/value/text.hpp
+2
-0
src/util/tagged_string.cpp
src/util/tagged_string.cpp
+35
-14
No files found.
src/data/keyword.hpp
View file @
60441224
...
...
@@ -111,8 +111,6 @@ class KeywordDatabase {
void
add
(
const
vector
<
KeywordP
>&
);
/// Add a keyword to be matched
void
add
(
const
Keyword
&
);
/// Remove a keyword from the database
void
remove
(
const
Keyword
&
);
/// Prepare the parameters and match regex for a list of keywords
static
void
prepare_parameters
(
const
vector
<
KeywordParamP
>&
,
const
vector
<
KeywordP
>&
);
...
...
src/gui/control/card_editor.cpp
View file @
60441224
...
...
@@ -161,6 +161,10 @@ void DataEditor::onCommand(int id) {
}
}
void
DataEditor
::
insert
(
const
String
&
text
,
const
String
&
action_name
)
{
if
(
current_editor
)
current_editor
->
insert
(
text
,
action_name
);
}
// ----------------------------------------------------------------------------- : Mouse events
void
DataEditor
::
onLeftDown
(
wxMouseEvent
&
ev
)
{
...
...
src/gui/control/card_editor.hpp
View file @
60441224
...
...
@@ -70,6 +70,11 @@ class DataEditor : public CardViewer {
*/
bool
search
(
FindInfo
&
find
,
bool
from_start
);
// --------------------------------------------------- : Selection in editor
/// Insert 'text' into the current editor, using an action with the given name
void
insert
(
const
String
&
text
,
const
String
&
action_name
);
// --------------------------------------------------- : ValueViewers
protected:
...
...
src/gui/control/text_ctrl.cpp
View file @
60441224
...
...
@@ -91,6 +91,9 @@ void TextCtrl::onChangeSet() {
}
else
{
setValue
(
nullptr
);
}
// select the one and only editor
current_viewer
=
viewers
.
front
().
get
();
current_editor
=
current_viewer
->
getEditor
();
}
void
TextCtrl
::
onInit
()
{
...
...
src/gui/set/keywords_panel.cpp
View file @
60441224
...
...
@@ -138,8 +138,6 @@ void KeywordsPanel::onUpdateUI(wxUpdateUIEvent& ev) {
case
ID_KEYWORD_PREV
:
ev
.
Enable
(
list
->
canSelectPrevious
());
break
;
case
ID_KEYWORD_NEXT
:
ev
.
Enable
(
list
->
canSelectNext
());
break
;
case
ID_KEYWORD_REMOVE
:
ev
.
Enable
(
list
->
getKeyword
()
&&
!
list
->
getKeyword
()
->
fixed
);
break
;
case
ID_KEYWORD_ADD_PARAM
:
break
;
}
}
...
...
@@ -192,27 +190,38 @@ void KeywordsPanel::onCommand(int id) {
if
(
id
>=
ID_PARAM_TYPE_MIN
&&
id
<
ID_PARAM_TYPE_MAX
)
{
// add parameter
KeywordParamP
param
=
set
->
game
->
keyword_parameter_types
.
at
(
id
-
ID_PARAM_TYPE_MIN
);
String
to_insert
=
_
(
"<atom-
keyword>"
)
+
param
->
name
+
_
(
"</atom-keyword
>"
);
// TODO
String
to_insert
=
_
(
"<atom-
param>"
)
+
param
->
name
+
_
(
"</atom-param
>"
);
match
->
insert
(
to_insert
,
_
(
"Insert parameter"
));
}
else
if
(
id
>=
ID_PARAM_REF_MIN
&&
id
<
ID_PARAM_REF_MAX
)
{
/*
int i = ID_PARAM_REF_MIN;
String
to_insert
=
runRefScript
(
id
-
ID_PARAM_REF_MIN
);
reminder
->
insert
(
to_insert
,
_
(
"Use parameter"
));
}
}
}
String
KeywordsPanel
::
runRefScript
(
int
find_i
)
{
int
param
=
0
;
int
i
=
0
;
FOR_EACH
(
p
,
list
->
getKeyword
()
->
parameters
)
{
String
param_s
=
String
(
_
(
"param"
))
<<
++
param
;
if
(
p
->
refer_scripts
.
empty
())
{
if (i == id
) {
if
(
i
++
==
find_i
)
{
// found it
} else {
return
_
(
"{"
)
+
param_s
+
_
(
"}"
);
}
}
else
{
FOR_EACH
(
r
,
p
->
refer_scripts
)
{
if
(
i
++
==
find_i
)
{
Context
&
ctx
=
set
->
getContext
();
ctx
.
setVariable
(
_
(
"input"
),
to_script
(
param_s
));
return
r
->
script
.
invoke
(
ctx
)
->
toString
();
}
}
String to_insert = list->getKeyword()->run_ref_script(id - ID_PARAM_REF_MIN, set->getContext());
*/
// TODO
}
}
return
wxEmptyString
;
}
// ----------------------------------------------------------------------------- : Events
void
KeywordsPanel
::
onChangeSet
()
{
...
...
@@ -250,12 +259,21 @@ void KeywordsPanel::onChangeSet() {
void
KeywordsPanel
::
onAction
(
const
Action
&
action
,
bool
undone
)
{
TYPE_CASE
(
action
,
ValueAction
)
{
{
KeywordReminderTextValue
*
value
=
dynamic_cast
<
KeywordReminderTextValue
*>
(
action
.
valueP
.
get
());
if
(
value
&&
&
value
->
keyword
==
list
->
getKeyword
().
get
())
{
// the current keyword's reminder text changed
errors
->
SetLabel
(
value
->
errors
);
}
}
{
KeywordTextValue
*
value
=
dynamic_cast
<
KeywordTextValue
*>
(
action
.
valueP
.
get
());
if
(
value
&&
value
->
underlying
==
&
list
->
getKeyword
()
->
match
)
{
// match string changes, maybe there are parameters now
ref_param
->
Enable
(
!
value
->
keyword
.
fixed
&&
!
value
->
keyword
.
parameters
.
empty
());
}
}
}
TYPE_CASE
(
action
,
ChangeKeywordModeAction
)
{
if
(
&
action
.
keyword
==
list
->
getKeyword
().
get
())
{
// the current keyword's mode changed
...
...
src/gui/set/keywords_panel.hpp
View file @
60441224
...
...
@@ -39,6 +39,9 @@ class KeywordsPanel : public SetWindowPanel {
private:
DECLARE_EVENT_TABLE
();
/// Find the code to insert based on the ref_scripts for the parameters of the current keyword
String
runRefScript
(
int
i
);
// --------------------------------------------------- : Controls
wxSplitterWindow
*
splitter
;
wxPanel
*
panel
;
...
...
src/gui/value/editor.hpp
View file @
60441224
...
...
@@ -69,11 +69,11 @@ class ValueEditor {
/// This editor can be pasted to right now
/** this function should also check the data on the clipboard has the right format */
virtual
bool
canPaste
()
const
{
return
false
;
}
// Copies from this field editor, returns success
//
/
Copies from this field editor, returns success
virtual
bool
doCopy
()
{
return
false
;
}
// Deletes the selection from this field editor, cut = copy + delete, returns success
//
/
Deletes the selection from this field editor, cut = copy + delete, returns success
virtual
bool
doDelete
()
{
return
false
;
}
// Cuts the selection from this field editor
//
/
Cuts the selection from this field editor
bool
doCut
()
{
return
doCopy
()
&&
doDelete
();
}
/// Initiate pasting in this field editor,
/** should again check if pasting is possible and fail silently if not, returns success */
...
...
@@ -96,6 +96,9 @@ class ValueEditor {
virtual
size_t
selectionStart
()
const
{
return
0
;
}
virtual
size_t
selectionEnd
()
const
{
return
0
;
}
/// Insert the given text (replacing the current selection)
virtual
void
insert
(
const
String
&
text
,
const
String
&
action_name
)
{};
// --------------------------------------------------- : Search / replace
/// Do a search or replace action for the given FindInfo
...
...
src/gui/value/text.cpp
View file @
60441224
...
...
@@ -218,8 +218,8 @@ void TextValueEditor::onLoseFocus() {
assert
(
caret
);
if
(
caret
->
IsVisible
())
caret
->
Hide
();
// hide selection
selection_start
=
selection_end
=
0
;
selection_start_i
=
selection_end_i
=
0
;
//
selection_start = selection_end = 0;
//
selection_start_i = selection_end_i = 0;
}
bool
TextValueEditor
::
onContextMenu
(
IconMenu
&
m
,
wxContextMenuEvent
&
ev
)
{
...
...
@@ -478,6 +478,9 @@ void TextValueEditor::showCaret() {
if
(
!
caret
->
IsVisible
())
caret
->
Show
();
}
void
TextValueEditor
::
insert
(
const
String
&
text
,
const
String
&
action_name
)
{
replaceSelection
(
text
,
action_name
);
}
void
TextValueEditor
::
replaceSelection
(
const
String
&
replacement
,
const
String
&
name
)
{
if
(
replacement
.
empty
()
&&
selection_start
==
selection_end
)
{
// no text selected, nothing to delete
...
...
src/gui/value/text.hpp
View file @
60441224
...
...
@@ -92,6 +92,8 @@ class TextValueEditor : public TextValueViewer, public ValueEditor {
virtual
size_t
selectionStart
()
const
{
return
selection_start
;
}
virtual
size_t
selectionEnd
()
const
{
return
selection_end
;
}
virtual
void
insert
(
const
String
&
text
,
const
String
&
action_name
);
// --------------------------------------------------- : Other
virtual
wxCursor
cursor
()
const
;
...
...
src/util/tagged_string.cpp
View file @
60441224
...
...
@@ -390,7 +390,10 @@ String get_tags(const String& str, size_t start, size_t end, bool close_tags) {
}
}
if
(
intag
&&
keeptag
)
ret
+=
c
;
if
(
c
==
_
(
'>'
))
intag
=
false
;
if
(
c
==
_
(
'>'
))
{
intag
=
false
;
keeptag
=
false
;
}
}
return
ret
;
}
...
...
@@ -399,12 +402,21 @@ String tagged_substr_replace(const String& input, size_t start, size_t end, cons
assert
(
start
<=
end
);
size_t
size
=
input
.
size
();
String
ret
;
ret
.
reserve
(
size
+
replacement
.
size
()
-
(
end
-
start
));
// estimated size
if
(
replacement
.
empty
())
{
return
simplify_tagged
(
substr_replace
(
input
,
start
,
end
,
get_tags
(
input
,
start
,
end
,
false
)
+
// open tags
replacement
+
get_tags
(
input
,
start
,
end
,
true
)
// close tags
));
}
else
{
return
simplify_tagged
(
substr_replace
(
input
,
start
,
end
,
get_tags
(
input
,
start
,
end
,
true
)
+
// close tags
replacement
+
get_tags
(
input
,
start
,
end
,
false
)
// open tags
));
}
}
...
...
@@ -419,6 +431,11 @@ String simplify_tagged(const String& str) {
// otherwise appends <tag> and returns fales
// (where </tag> is the negation of tag)
bool
add_or_cancel_tag
(
const
String
&
tag
,
String
&
stack
)
{
if
(
starts_with
(
tag
,
_
(
"b"
))
||
starts_with
(
tag
,
_
(
"i"
))
||
starts_with
(
tag
,
_
(
"sym"
))
||
starts_with
(
tag
,
_
(
"/"
)))
{
// cancel out all close tags, but not all open tags,
// so <xx></xx> is always removed
// but </xx><xx> is not
String
anti
=
anti_tag
(
tag
);
size_t
pos
=
stack
.
find
(
anti
);
if
(
pos
==
String
::
npos
)
{
...
...
@@ -429,6 +446,10 @@ bool add_or_cancel_tag(const String& tag, String& stack) {
stack
=
stack
.
substr
(
0
,
pos
)
+
stack
.
substr
(
pos
+
anti
.
size
());
return
true
;
}
}
else
{
stack
+=
_
(
"<"
)
+
tag
+
_
(
">"
);
return
false
;
}
}
String
simplify_tagged_merge
(
const
String
&
str
)
{
...
...
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