### ----------------------------------------------------
### -- Terminal::LineEditor
### -- Licenses: Artistic-2.0
### -- Authors: Geoffrey Broadwell
### -- File: lib/Terminal/LineEditor/RawTerminalInput.rakumod
### ----------------------------------------------------
### -- Chunk 2 of 2
ions;
                }
                orwith $key && %!keymap{$key} {
                    when 'complete'        { do-complete }
                    reset-completions;

                    when 'literal-next'    { $literal-mode = True }
                    when 'history-start'   { do-history-start }
                    when 'history-prev'    { do-history-prev }
                    when 'history-next'    { do-history-next }
                    when 'history-end'     { do-history-end }
                    when 'suspend'         { self.suspend(:&on-suspend, :&on-continue);
                                             $.input-field.force-pos-to-start;
                                             self.do-edit('insert-string', ''); }
                    when 'finish'          { self.set-done; done }
                    when 'abort-input'     { self.set-done; $aborted = True; done }
                    when 'abort-or-delete' { unless $.input-field.buffer.contents {
                                                   self.set-done;
                                                   $aborted = True;
                                                   done
                                               }
                                             self.do-edit('delete-char-forward') }
                    default                { self.do-edit($_) }
                }
            }
        }

        # Return final buffer contents (or Str if aborted)
        $aborted ?? Str !! $.input-field.buffer.contents
    }

    #| Print and flush prompt then enter input loop, optionally masking password
    method prompt(Str:D $prompt = '', Str :$mask --> Str) {
        my sub flush-prompt() {
            $.output.print($prompt);
            $.output.flush;
        }

        flush-prompt;
        self.read-input(:$mask, :on-continue(&flush-prompt))
    }
}


