diff options
author | Florian Merz <flomerz@gmail.com> | 2015-10-21 22:38:23 +0200 |
---|---|---|
committer | Florian Merz <flomerz@gmail.com> | 2015-10-21 22:38:23 +0200 |
commit | 80e8a674e219a6b65e070675d1775f0bd0e2ad93 (patch) | |
tree | fdb61988cab71851cdb342ee1f49a21c57cc3d83 /components/script/textinput.rs | |
parent | 50ec2353845bf2a3971d5b01db37d2c3741d3912 (diff) | |
download | servo-80e8a674e219a6b65e070675d1775f0bd0e2ad93.tar.gz servo-80e8a674e219a6b65e070675d1775f0bd0e2ad93.zip |
display input caret for textarea. fixes #7758
Diffstat (limited to 'components/script/textinput.rs')
-rw-r--r-- | components/script/textinput.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/components/script/textinput.rs b/components/script/textinput.rs index 627ecf29a5f..c75d246d3ba 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -455,4 +455,14 @@ impl<T: ClipboardProvider> TextInput<T> { self.edit_point.line = min(self.edit_point.line, self.lines.len() - 1); self.edit_point.index = min(self.edit_point.index, self.current_line_length()); } + + pub fn get_absolute_insertion_point(&self) -> usize { + self.lines.iter().enumerate().fold(0, |acc, (i, val)| { + if i < self.edit_point.line { + acc + val.len() + 1 // +1 for the \n + } else { + acc + } + }) + self.edit_point.index + } } |