Skip to content

Commit

Permalink
Merge pull request #157 from non/topic/cd-delete
Browse files Browse the repository at this point in the history
Enable C-d to delete when line is not empty.
  • Loading branch information
lihaoyi committed Aug 12, 2015
2 parents cd5de73 + df72f00 commit 2c2fb22
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions terminal/src/main/scala/ammonite/terminal/BasicFilters.scala
Expand Up @@ -73,9 +73,17 @@ object BasicFilters {
case TS(13 ~: 10 ~:rest, b, c) => // Enter
Result(b.mkString)
}

lazy val exitFilter: TermCore.Filter = {
case TS(Ctrl('c') ~: rest, b, c) => Result("")
case TS(Ctrl('d') ~: rest, b, c) => Exit
case TS(Ctrl('c') ~: rest, b, c) =>
Result("")
case TS(Ctrl('d') ~: rest, b, c) =>
// only exit if the line is empty, otherwise, behave like
// "delete" (i.e. delete one char to the right)
if (b.isEmpty) Exit else {
val (first, last) = b.splitAt(c)
TS(rest, first ++ last.drop(1), c)
}
}

def moveStart(b: Vector[Char],
Expand Down

0 comments on commit 2c2fb22

Please sign in to comment.