mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
display input caret for textarea. fixes #7758
This commit is contained in:
parent
50ec235384
commit
80e8a674e2
6 changed files with 67 additions and 21 deletions
|
@ -11,7 +11,7 @@ use std::borrow::ToOwned;
|
|||
use std::ffi::CStr;
|
||||
use std::iter::{Filter, Peekable};
|
||||
use std::ops::Deref;
|
||||
use std::str::{FromStr, Split, from_utf8};
|
||||
use std::str::{CharIndices, FromStr, Split, from_utf8};
|
||||
|
||||
pub type DOMString = String;
|
||||
pub type StaticCharVec = &'static [char];
|
||||
|
@ -420,3 +420,16 @@ pub fn slice_chars(s: &str, begin: usize, end: usize) -> &str {
|
|||
(Some(a), Some(b)) => unsafe { s.slice_unchecked(a, b) }
|
||||
}
|
||||
}
|
||||
|
||||
// searches a character index in CharIndices
|
||||
// returns indices.count if not found
|
||||
pub fn search_index(index: usize, indices: CharIndices) -> isize {
|
||||
let mut character_count = 0;
|
||||
for (character_index, _) in indices {
|
||||
if character_index == index {
|
||||
return character_count;
|
||||
}
|
||||
character_count += 1
|
||||
}
|
||||
character_count
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue