_from_typing: bool=true, _emit: bool=true
(&self, str: String, from_typing: bool, emit: bool)
| 126 | #[inline] |
| 127 | // _from_typing: bool=true, _emit: bool=true |
| 128 | fn refresh(&self, str: String, from_typing: bool, emit: bool) -> String { |
| 129 | let mut state = self.state.borrow_mut(); |
| 130 | state.edit = str.clone(); |
| 131 | |
| 132 | match state.display_char { |
| 133 | Some(ch) => { |
| 134 | state.display = String::new(); |
| 135 | for i in 0..str.len() { |
| 136 | state.display.push(ch); |
| 137 | } |
| 138 | } |
| 139 | None => { |
| 140 | let state = self.state.borrow(); |
| 141 | let index = state.index as usize; |
| 142 | self.state.borrow_mut().display = format!( |
| 143 | "{}{}{}", |
| 144 | self.before(index), |
| 145 | state.composition, |
| 146 | self.after(index) |
| 147 | ); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | let state = self.state.borrow(); |
| 152 | self.label.set_text(state.display.clone()); |
| 153 | self.update_cur(); |
| 154 | |
| 155 | if emit { |
| 156 | self.onchange.emit(&TextEditChangeEvent { |
| 157 | text: state.edit.clone(), |
| 158 | display_text: state.display.clone(), |
| 159 | from_typing, |
| 160 | }); |
| 161 | } |
| 162 | |
| 163 | state.edit.clone() |
| 164 | } |
| 165 | |
| 166 | pub fn index(&self) -> i32 { |
| 167 | self.state.borrow().index |
no test coverage detected