on master help sign in
Support entering newlines.
eb6b9a9Blaž Hrastnik
helix-term/src/editor.rs+5−18
@@ -185,23 +185,6 @@ impl Editor {
185 // .take(self.size.1 as usize)
185 // .take(self.size.1 as usize)
186 // .map(|x| x.as_str().unwrap());
186 // .map(|x| x.as_str().unwrap());
187
187
188− // for (n, line) in lines.enumerate() {
189− // execute!(
190− // stdout,
191− // SetForegroundColor(Color::DarkCyan),
192− // cursor::MoveTo(0, n as u16),
193− // Print((n + 1).to_string())
194− // );
195−
196− // surface.set_string(2, n as u16, line, Style::default());
197− // // execute!(
198− // // stdout,
199− // // SetForegroundColor(Color::Reset),
200− // // cursor::MoveTo(2, n as u16),
201− // // Print(line)
202− // // );
203− // }
204−
205 // // iterate over selections and render them
188 // // iterate over selections and render them
206 // let select = Style::default().bg(tui::style::Color::LightBlue);
189 // let select = Style::default().bg(tui::style::Color::LightBlue);
207 // let text = state.doc.slice(..);
190 // let text = state.doc.slice(..);
@@ -234,7 +217,7 @@ impl Editor {
234 // );
217 // );
235
218
236 use tui::backend::Backend;
219 use tui::backend::Backend;
237− // // TODO: double buffer and diff here
220+
238 self.terminal
221 self.terminal
239 .backend_mut()
222 .backend_mut()
240 .draw(self.surface.diff(&surface).into_iter());
223 .draw(self.surface.diff(&surface).into_iter());
@@ -296,6 +279,10 @@ impl Editor {
296 code: KeyCode::Char(c),
279 code: KeyCode::Char(c),
297 ..
280 ..
298 } => helix_core::commands::insert_char(state, c),
281 } => helix_core::commands::insert_char(state, c),
282+ KeyEvent {
283+ code: KeyCode::Enter,
284+ ..
285+ } => helix_core::commands::insert_char(state, '\n'),
299 _ => (), // skip
286 _ => (), // skip
300 }
287 }
301 self.render();
288 self.render();