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