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
1cfe91f5
Commit
1cfe91f5
authored
Dec 26, 2006
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved selection
parent
c1da87cb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
14 deletions
+18
-14
src/gui/value/text.cpp
src/gui/value/text.cpp
+1
-1
src/util/tagged_string.cpp
src/util/tagged_string.cpp
+17
-13
No files found.
src/gui/value/text.cpp
View file @
1cfe91f5
...
...
@@ -563,7 +563,7 @@ size_t TextValueEditor::prevCharBoundry(size_t pos) const {
return
max
(
0
,
(
int
)
pos
-
1
);
}
size_t
TextValueEditor
::
nextCharBoundry
(
size_t
pos
)
const
{
return
pos
+
1
;
return
min
(
index_to_cursor
(
value
().
value
(),
String
::
npos
),
pos
+
1
)
;
}
size_t
TextValueEditor
::
prevWordBoundry
(
size_t
pos_i
)
const
{
const
String
&
val
=
value
().
value
();
...
...
src/util/tagged_string.cpp
View file @
1cfe91f5
...
...
@@ -167,38 +167,41 @@ String anti_tag(const String& tag) {
size_t
index_to_cursor
(
const
String
&
str
,
size_t
index
,
Movement
dir
)
{
size_t
cursor
=
0
;
size_t
start
=
0
,
end
=
0
;
index
=
min
(
index
,
str
.
size
());
// find the range [start...end) with the same cursor value, that contains index
// after the loop,
cursor corresponds to index
end
for
(
size_t
i
=
0
;
i
<
str
.
size
()
;
)
{
// after the loop,
'cursor' corresponds to the index i/
end
for
(
size_t
i
=
0
;
i
<
str
.
size
()
;)
{
Char
c
=
str
.
GetChar
(
i
);
bool
has_width
=
true
;
if
(
c
==
_
(
'<'
))
{
// a tag
if
(
is_substr
(
str
,
i
,
_
(
"<atom"
))
||
is_substr
(
str
,
i
,
_
(
"<sep"
)))
{
// skip tag contents, tag counts as a single 'character'
i
=
skip_tag
(
str
,
match_close_tag
(
str
,
i
));
size_t
before
=
i
;
size_t
after
=
skip_tag
(
str
,
match_close_tag
(
str
,
i
));
if
(
index
>
before
&&
index
<
after
)
{
// index is inside an atom, determine on which side we want the cursor
if
(
dir
==
MOVE_RIGHT
)
{
return
cursor
+
1
;
}
else
if
(
dir
==
MOVE_MID
)
{
// take the closest side
return
cursor
+
((
int
)(
after
-
index
)
<
(
int
)(
index
-
before
));
}
}
i
=
after
;
}
else
{
i
=
skip_tag
(
str
,
i
);
end
=
i
;
has_width
=
false
;
}
}
else
{
i
++
;
}
if
(
i
>
index
)
break
;
if
(
has_width
)
{
cursor
++
;
start
=
end
;
end
=
i
;
if
(
end
>
index
)
break
;
}
}
if
(
cursor
==
0
)
return
0
;
if
(
dir
==
MOVE_LEFT
)
return
cursor
-
1
;
if
(
dir
==
MOVE_RIGHT
)
return
cursor
-
(
start
==
index
);
// which is nearer? start or end?
return
cursor
-
((
int
)(
index
-
start
)
<=
(
int
)(
end
-
index
));
return
cursor
;
}
void
cursor_to_index_range
(
const
String
&
str
,
size_t
cursor
,
size_t
&
start
,
size_t
&
end
)
{
...
...
@@ -227,6 +230,7 @@ void cursor_to_index_range(const String& str, size_t cursor, size_t& start, size
}
end
=
min
(
i
,
str
.
size
());
if
(
cur
<
cursor
)
start
=
end
=
str
.
size
();
if
(
end
<=
start
)
end
=
start
+
1
;
}
size_t
cursor_to_index
(
const
String
&
str
,
size_t
cursor
,
Movement
dir
)
{
...
...
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