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
59b414df
Commit
59b414df
authored
Apr 23, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
find/replace working better (but not done yet)
parent
fcc72286
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
7 deletions
+37
-7
src/gui/set/cards_panel.cpp
src/gui/set/cards_panel.cpp
+9
-4
src/gui/value/text.cpp
src/gui/value/text.cpp
+8
-3
src/util/tagged_string.cpp
src/util/tagged_string.cpp
+15
-0
src/util/tagged_string.hpp
src/util/tagged_string.hpp
+5
-0
No files found.
src/gui/set/cards_panel.cpp
View file @
59b414df
...
@@ -271,7 +271,7 @@ void CardsPanel::doPaste() { CUT_COPY_PASTE(doPaste, ;) }
...
@@ -271,7 +271,7 @@ void CardsPanel::doPaste() { CUT_COPY_PASTE(doPaste, ;) }
class
CardsPanel
::
SearchFindInfo
:
public
FindInfo
{
class
CardsPanel
::
SearchFindInfo
:
public
FindInfo
{
public:
public:
SearchFindInfo
(
CardsPanel
&
panel
,
wxFindReplaceData
&
what
)
:
FindInfo
(
what
),
panel
(
panel
)
{}
SearchFindInfo
(
CardsPanel
&
panel
,
wxFindReplaceData
&
what
)
:
FindInfo
(
what
),
panel
(
panel
)
{}
virtual
bool
handle
(
const
CardP
&
card
,
const
TextValueP
&
value
,
size_t
pos
)
{
virtual
bool
handle
(
const
CardP
&
card
,
const
TextValueP
&
value
,
size_t
pos
,
bool
was_selection
)
{
// Select the card
// Select the card
panel
.
card_list
->
setCard
(
card
);
panel
.
card_list
->
setCard
(
card
);
return
true
;
return
true
;
...
@@ -283,13 +283,18 @@ class CardsPanel::SearchFindInfo : public FindInfo {
...
@@ -283,13 +283,18 @@ class CardsPanel::SearchFindInfo : public FindInfo {
class
CardsPanel
::
ReplaceFindInfo
:
public
FindInfo
{
class
CardsPanel
::
ReplaceFindInfo
:
public
FindInfo
{
public:
public:
ReplaceFindInfo
(
CardsPanel
&
panel
,
wxFindReplaceData
&
what
)
:
FindInfo
(
what
),
panel
(
panel
)
{}
ReplaceFindInfo
(
CardsPanel
&
panel
,
wxFindReplaceData
&
what
)
:
FindInfo
(
what
),
panel
(
panel
)
{}
virtual
bool
handle
(
const
CardP
&
card
,
const
TextValueP
&
value
,
size_t
pos
)
{
virtual
bool
handle
(
const
CardP
&
card
,
const
TextValueP
&
value
,
size_t
pos
,
bool
was_selection
)
{
// Select the card
// Select the card
panel
.
card_list
->
setCard
(
card
);
panel
.
card_list
->
setCard
(
card
);
// Replace
// Replace
panel
.
editor
->
insert
(
escape
(
what
.
GetReplaceString
()),
_
(
"Replace"
));
if
(
was_selection
)
{
return
true
;
panel
.
editor
->
insert
(
escape
(
what
.
GetReplaceString
()),
_
(
"Replace"
));
return
false
;
}
else
{
return
true
;
}
}
}
virtual
bool
searchSelection
()
const
{
return
true
;
}
private:
private:
CardsPanel
&
panel
;
CardsPanel
&
panel
;
};
};
...
...
src/gui/value/text.cpp
View file @
59b414df
...
@@ -677,14 +677,17 @@ bool TextValueEditor::matchSubstr(const String& s, size_t pos, FindInfo& find) {
...
@@ -677,14 +677,17 @@ bool TextValueEditor::matchSubstr(const String& s, size_t pos, FindInfo& find) {
if
(
!
is_substr
(
s
,
pos
,
find
.
findString
().
Lower
()))
return
false
;
if
(
!
is_substr
(
s
,
pos
,
find
.
findString
().
Lower
()))
return
false
;
}
}
// handle
// handle
bool
was_selection
=
false
;
if
(
find
.
select
())
{
if
(
find
.
select
())
{
editor
().
select
(
this
);
editor
().
select
(
this
);
editor
().
SetFocus
();
editor
().
SetFocus
();
size_t
old_sel_start
=
selection_start
,
old_sel_end
=
selection_end
;
selection_start_i
=
untagged_to_index
(
value
().
value
(),
pos
,
true
);
selection_start_i
=
untagged_to_index
(
value
().
value
(),
pos
,
true
);
selection_end_i
=
untagged_to_index
(
value
().
value
(),
pos
+
find
.
findString
().
size
(),
true
);
selection_end_i
=
untagged_to_index
(
value
().
value
(),
pos
+
find
.
findString
().
size
(),
true
);
fixSelection
(
TYPE_INDEX
);
fixSelection
(
TYPE_INDEX
);
was_selection
=
old_sel_start
==
selection_start
&&
old_sel_end
==
selection_end
;
}
}
if
(
find
.
handle
(
viewer
.
getCard
(),
valueP
(),
pos
))
{
if
(
find
.
handle
(
viewer
.
getCard
(),
valueP
(),
pos
,
was_selection
))
{
return
true
;
return
true
;
}
else
{
}
else
{
// TODO: string might have changed when doing replace all
// TODO: string might have changed when doing replace all
...
@@ -695,15 +698,17 @@ bool TextValueEditor::matchSubstr(const String& s, size_t pos, FindInfo& find) {
...
@@ -695,15 +698,17 @@ bool TextValueEditor::matchSubstr(const String& s, size_t pos, FindInfo& find) {
bool
TextValueEditor
::
search
(
FindInfo
&
find
,
bool
from_start
)
{
bool
TextValueEditor
::
search
(
FindInfo
&
find
,
bool
from_start
)
{
String
v
=
untag
(
value
().
value
());
String
v
=
untag
(
value
().
value
());
if
(
!
find
.
caseSensitive
())
v
.
LowerCase
();
if
(
!
find
.
caseSensitive
())
v
.
LowerCase
();
size_t
selection_min
=
index_to_untagged
(
value
().
value
(),
min
(
selection_start_i
,
selection_end_i
));
size_t
selection_max
=
index_to_untagged
(
value
().
value
(),
max
(
selection_start_i
,
selection_end_i
));
if
(
find
.
forward
())
{
if
(
find
.
forward
())
{
size_t
start
=
min
(
v
.
size
(),
max
(
selection_start
,
selection_end
)
);
size_t
start
=
min
(
v
.
size
(),
find
.
searchSelection
()
?
selection_min
:
selection_max
);
size_t
end
=
max
(
0
,
(
int
)
v
.
size
()
-
(
int
)
find
.
findString
().
size
());
size_t
end
=
max
(
0
,
(
int
)
v
.
size
()
-
(
int
)
find
.
findString
().
size
());
for
(
size_t
i
=
start
;
i
<=
end
;
++
i
)
{
for
(
size_t
i
=
start
;
i
<=
end
;
++
i
)
{
if
(
matchSubstr
(
v
,
i
,
find
))
return
true
;
if
(
matchSubstr
(
v
,
i
,
find
))
return
true
;
}
}
}
else
{
}
else
{
size_t
start
=
0
;
size_t
start
=
0
;
int
end
=
(
int
)
min
(
selection_start
,
selection_end
)
-
(
int
)
find
.
findString
().
size
();
int
end
=
(
int
)
(
find
.
searchSelection
()
?
selection_max
:
selection_min
)
-
(
int
)
find
.
findString
().
size
();
if
(
end
<
0
)
return
false
;
if
(
end
<
0
)
return
false
;
for
(
size_t
i
=
end
;
i
>=
start
;
--
i
)
{
for
(
size_t
i
=
end
;
i
>=
start
;
--
i
)
{
if
(
matchSubstr
(
v
,
i
,
find
))
return
true
;
if
(
matchSubstr
(
v
,
i
,
find
))
return
true
;
...
...
src/util/tagged_string.cpp
View file @
59b414df
...
@@ -329,6 +329,21 @@ size_t untagged_to_index(const String& str, size_t pos, bool inside) {
...
@@ -329,6 +329,21 @@ size_t untagged_to_index(const String& str, size_t pos, bool inside) {
return
i
;
return
i
;
}
}
size_t
index_to_untagged
(
const
String
&
str
,
size_t
index
)
{
size_t
i
=
0
,
p
=
0
;
index
=
min
(
str
.
size
(),
index
);
while
(
i
<
index
)
{
Char
c
=
str
.
GetChar
(
i
);
if
(
c
==
_
(
'<'
))
{
i
=
skip_tag
(
str
,
i
);
}
else
{
i
++
;
p
++
;
}
}
return
p
;
}
// ----------------------------------------------------------------------------- : Global operations
// ----------------------------------------------------------------------------- : Global operations
String
remove_tag
(
const
String
&
str
,
const
String
&
tag
)
{
String
remove_tag
(
const
String
&
str
,
const
String
&
tag
)
{
...
...
src/util/tagged_string.hpp
View file @
59b414df
...
@@ -119,6 +119,11 @@ size_t cursor_to_index(const String& str, size_t cursor, Movement dir = MOVE_MID
...
@@ -119,6 +119,11 @@ size_t cursor_to_index(const String& str, size_t cursor, Movement dir = MOVE_MID
*/
*/
size_t
untagged_to_index
(
const
String
&
str
,
size_t
pos
,
bool
inside
);
size_t
untagged_to_index
(
const
String
&
str
,
size_t
pos
,
bool
inside
);
/// Find the untagged position corresponding to the given tagged position.
/** An untagged position in str is a position in untag(str).
*/
size_t
index_to_untagged
(
const
String
&
str
,
size_t
index
);
// ----------------------------------------------------------------------------- : Global operations
// ----------------------------------------------------------------------------- : Global operations
/// Remove all instances of a tag and its close tag, but keep the contents.
/// Remove all instances of a tag and its close tag, but keep the contents.
...
...
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