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
c24b5bd3
Commit
c24b5bd3
authored
Dec 24, 2006
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
formating works, cursor position now prefers to be inside tags
parent
475d0faa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
12 deletions
+13
-12
src/gui/value/text.cpp
src/gui/value/text.cpp
+8
-4
src/mse.vcproj
src/mse.vcproj
+0
-3
src/util/tagged_string.cpp
src/util/tagged_string.cpp
+4
-4
src/util/tagged_string.hpp
src/util/tagged_string.hpp
+1
-1
No files found.
src/gui/value/text.cpp
View file @
c24b5bd3
...
...
@@ -354,6 +354,7 @@ bool TextValueEditor::hasFormat(int type) const {
}
void
TextValueEditor
::
doFormat
(
int
type
)
{
size_t
ss
=
selection_start
,
se
=
selection_end
;
switch
(
type
)
{
case
ID_FORMAT_BOLD
:
{
getSet
().
actions
.
add
(
toggle_format_action
(
valueP
(),
_
(
"b"
),
selection_start_i
,
selection_end_i
,
_
(
"Bold"
)));
...
...
@@ -368,6 +369,9 @@ void TextValueEditor::doFormat(int type) {
break
;
}
}
selection_start
=
ss
;
selection_end
=
se
;
fixSelection
();
}
// ----------------------------------------------------------------------------- : Selection
...
...
@@ -534,8 +538,8 @@ void TextValueEditor::fixSelection(IndexType t, Movement dir) {
selection_end
=
index_to_cursor
(
value
().
value
(),
selection_end_i
,
dir
);
}
// make sure the selection is at a valid position inside the text
selection_start_i
=
cursor_to_index
(
val
,
selection_start
);
selection_end_i
=
cursor_to_index
(
val
,
selection_end
);
selection_start_i
=
cursor_to_index
(
val
,
selection_start
,
selection_start
==
selection_end
?
MOVE_MID
:
MOVE_RIGHT
);
selection_end_i
=
cursor_to_index
(
val
,
selection_end
,
selection_start
==
selection_end
?
MOVE_MID
:
MOVE_LEFT
);
// start and end must be on the same side of separators
size_t
seppos
=
val
.
find
(
_
(
"<sep"
));
while
(
seppos
!=
String
::
npos
)
{
...
...
@@ -543,11 +547,11 @@ void TextValueEditor::fixSelection(IndexType t, Movement dir) {
if
(
selection_start_i
<=
seppos
&&
selection_end_i
>
seppos
)
{
// not on same side, move selection end before sep
selection_end
=
index_to_cursor
(
val
,
seppos
,
dir
);
selection_end_i
=
cursor_to_index
(
val
,
selection_end
);
selection_end_i
=
cursor_to_index
(
val
,
selection_end
,
selection_start
==
selection_end
?
MOVE_MID
:
MOVE_LEFT
);
}
else
if
(
selection_start_i
>=
sepend
&&
selection_end_i
<
sepend
)
{
// not on same side, move selection end after sep
selection_end
=
index_to_cursor
(
val
,
sepend
,
dir
);
selection_end_i
=
cursor_to_index
(
val
,
selection_end
);
selection_end_i
=
cursor_to_index
(
val
,
selection_end
,
selection_start
==
selection_end
?
MOVE_MID
:
MOVE_LEFT
);
}
// find next separator
seppos
=
val
.
find
(
_
(
"<sep"
),
seppos
+
1
);
...
...
src/mse.vcproj
View file @
c24b5bd3
...
...
@@ -2526,9 +2526,6 @@
<File
RelativePath=
".\render\text\font.cpp"
>
</File>
<File
RelativePath=
".\render\text\line.cpp"
>
</File>
<File
RelativePath=
".\render\text\symbol.cpp"
>
<FileConfiguration
...
...
src/util/tagged_string.cpp
View file @
c24b5bd3
...
...
@@ -229,12 +229,12 @@ void cursor_to_index_range(const String& str, size_t cursor, size_t& start, size
if
(
cur
<
cursor
)
start
=
end
=
str
.
size
();
}
size_t
cursor_to_index
(
const
String
&
str
,
size_t
cursor
)
{
size_t
cursor_to_index
(
const
String
&
str
,
size_t
cursor
,
Movement
dir
)
{
size_t
start
,
end
;
cursor_to_index_range
(
str
,
cursor
,
start
,
end
);
// TODO: If at i there is <tag></tag> return a position inside the tags
// This allows formating to be enabled without a selection
return
start
;
return
dir
==
MOVE_RIGHT
?
end
-
1
:
start
;
}
...
...
@@ -373,12 +373,12 @@ String simplify_tagged_overlap(const String& str) {
add_or_cancel_tag
(
tag
,
open_tags
);
if
(
open_tags
.
find
(
anti_tag
(
tag
))
!=
String
::
npos
)
{
// still not canceled out
i
+=
tag
.
size
()
+
2
;
i
+=
tag
.
size
()
+
1
;
continue
;
}
}
else
{
// skip this tag, doubling it has no effect
i
+=
tag
.
size
()
+
2
;
i
+=
tag
.
size
()
+
1
;
add_or_cancel_tag
(
tag
,
open_tags
);
continue
;
}
...
...
src/util/tagged_string.hpp
View file @
c24b5bd3
...
...
@@ -101,7 +101,7 @@ size_t index_to_cursor(const String& str, size_t index, Movement dir = MOVE_MID)
void
cursor_to_index_range
(
const
String
&
str
,
size_t
cursor
,
size_t
&
begin
,
size_t
&
end
);
/// Find the character index corresponding to the given cursor position
size_t
cursor_to_index
(
const
String
&
str
,
size_t
cursor
);
size_t
cursor_to_index
(
const
String
&
str
,
size_t
cursor
,
Movement
dir
=
MOVE_MID
);
// ----------------------------------------------------------------------------- : Global operations
...
...
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