Skip to content

Commit

Permalink
Merge pull request nushell#2 from E3uka/implement-eof
Browse files Browse the repository at this point in the history
Implement EOF
  • Loading branch information
Jonathan Turner committed Mar 4, 2021
2 parents 794a004 + 3fb9f09 commit bf416d8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::io::{stdout, Write};

use crossterm::{
cursor::{position, MoveLeft, MoveRight, MoveToColumn},
cursor::{position, MoveLeft, MoveRight, MoveToColumn, MoveToNextLine},
event::read,
event::{Event, KeyCode, KeyEvent, KeyModifiers},
style::{Color, Print, ResetColor, SetForegroundColor},
Expand Down Expand Up @@ -48,6 +48,12 @@ fn main() -> Result<()> {
Event::Key(KeyEvent { code, modifiers }) => {
match code {
KeyCode::Char(c) => {
if modifiers == KeyModifiers::CONTROL {
if c == 'd' {
stdout.queue(MoveToNextLine(1))?.queue(Print("exit"))?;
break 'repl;
}
}
let insertion_point = caret_pos as usize - input_start_col as usize;
if insertion_point == buffer.len() {
stdout.queue(Print(c))?;
Expand Down

0 comments on commit bf416d8

Please sign in to comment.