Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
keyboard
LatinIME
Commits
1894c6e5
Commit
1894c6e5
authored
12 years ago
by
Ken Wakasa
Browse files
Options
Downloads
Patches
Plain Diff
Remove unused methods and classes
Change-Id: I1a82bf2202d436efa4c5135d705a048fe45a0257
parent
f8ad37a8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/src/com/android/inputmethod/latin/EditingUtils.java
+0
-75
0 additions, 75 deletions
java/src/com/android/inputmethod/latin/EditingUtils.java
with
0 additions
and
75 deletions
java/src/com/android/inputmethod/latin/EditingUtils.java
+
0
−
75
View file @
1894c6e5
...
...
@@ -16,7 +16,6 @@
package
com.android.inputmethod.latin
;
import
android.text.TextUtils
;
import
android.view.inputmethod.ExtractedText
;
import
android.view.inputmethod.ExtractedTextRequest
;
import
android.view.inputmethod.InputConnection
;
...
...
@@ -122,7 +121,6 @@ public class EditingUtils {
private
static
final
Pattern
spaceRegex
=
Pattern
.
compile
(
"\\s+"
);
public
static
CharSequence
getPreviousWord
(
InputConnection
connection
,
String
sentenceSeperators
)
{
//TODO: Should fix this. This could be slow!
...
...
@@ -181,77 +179,4 @@ public class EditingUtils {
return
w
[
w
.
length
-
1
];
}
public
static
class
SelectedWord
{
public
final
int
mStart
;
public
final
int
mEnd
;
public
final
CharSequence
mWord
;
public
SelectedWord
(
int
start
,
int
end
,
CharSequence
word
)
{
mStart
=
start
;
mEnd
=
end
;
mWord
=
word
;
}
}
/**
* Takes a character sequence with a single character and checks if the character occurs
* in a list of word separators or is empty.
* @param singleChar A CharSequence with null, zero or one character
* @param wordSeparators A String containing the word separators
* @return true if the character is at a word boundary, false otherwise
*/
private
static
boolean
isWordBoundary
(
CharSequence
singleChar
,
String
wordSeparators
)
{
return
TextUtils
.
isEmpty
(
singleChar
)
||
wordSeparators
.
contains
(
singleChar
);
}
/**
* Checks if the cursor is inside a word or the current selection is a whole word.
* @param ic the InputConnection for accessing the text field
* @param selStart the start position of the selection within the text field
* @param selEnd the end position of the selection within the text field. This could be
* the same as selStart, if there's no selection.
* @param wordSeparators the word separator characters for the current language
* @return an object containing the text and coordinates of the selected/touching word,
* null if the selection/cursor is not marking a whole word.
*/
public
static
SelectedWord
getWordAtCursorOrSelection
(
final
InputConnection
ic
,
int
selStart
,
int
selEnd
,
String
wordSeparators
)
{
if
(
selStart
==
selEnd
)
{
// There is just a cursor, so get the word at the cursor
// getWordRangeAtCursor returns null if the connection is null
final
EditingUtils
.
Range
range
=
getWordRangeAtCursor
(
ic
,
wordSeparators
);
if
(
range
!=
null
&&
!
TextUtils
.
isEmpty
(
range
.
mWord
))
{
return
new
SelectedWord
(
selStart
-
range
.
mCharsBefore
,
selEnd
+
range
.
mCharsAfter
,
range
.
mWord
);
}
}
else
{
if
(
null
==
ic
)
return
null
;
// Is the previous character empty or a word separator? If not, return null.
final
CharSequence
charsBefore
=
ic
.
getTextBeforeCursor
(
1
,
0
);
if
(!
isWordBoundary
(
charsBefore
,
wordSeparators
))
{
return
null
;
}
// Is the next character empty or a word separator? If not, return null.
final
CharSequence
charsAfter
=
ic
.
getTextAfterCursor
(
1
,
0
);
if
(!
isWordBoundary
(
charsAfter
,
wordSeparators
))
{
return
null
;
}
// Extract the selection alone
final
CharSequence
touching
=
ic
.
getSelectedText
(
0
);
if
(
TextUtils
.
isEmpty
(
touching
))
return
null
;
// Is any part of the selection a separator? If so, return null.
final
int
length
=
touching
.
length
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
if
(
wordSeparators
.
contains
(
touching
.
subSequence
(
i
,
i
+
1
)))
{
return
null
;
}
}
// Prepare the selected word
return
new
SelectedWord
(
selStart
,
selEnd
,
touching
);
}
return
null
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment