src/ui/prompt.js
// Open the prompt's dialog.
Open the prompt's dialog.
Open the prompt ' s dialog .
open() {
    this.close()
    let prompt = this.prompt()
    let hadFocus = this.pm.hasFocus()
    this.doClose = () => {
      prompt.close()
      if (hadFocus) setTimeout(() => this.pm.focus(), 50)
    }
    let submit = () => {
      let params = this.values()
      if (params) {
        this.close()
        this.command.exec(this.pm, params)
      }
    }
    this.form.addEventListener("submit", e => {
      e.preventDefault()
      submit()
    })
    this.form.addEventListener("keydown", e => {
      if (e.keyCode == 27)
        prompt.close()
      else if (e.keyCode == 13 && !(e.ctrlKey || e.metaKey || e.shiftKey))
        submit()
    })
    let input = this.form.querySelector("input, textarea")
    if (input) input.focus()
  }
open ( ) { this . close ( ) let prompt = this . prompt ( ) let hadFocus = this . pm . hasFocus ( ) this . doClose = ( ) => { prompt . close ( ) if ( hadFocus ) setTimeout ( ( ) => this . pm . focus ( ) , 50 ) } let submit = ( ) => { let params = this . values ( ) if ( params ) { this . close ( ) this . command . exec ( this . pm , params ) } } this . form . addEventListener ( "submit" , e => { e . preventDefault ( ) submit ( ) } ) this . form . addEventListener ( "keydown" , e => { if ( e . keyCode == 27 ) prompt . close ( ) else if ( e . keyCode == 13 && ! ( e . ctrlKey || e . metaKey || e . shiftKey ) ) submit ( ) } ) let input = this . form . querySelector ( "input, textarea" ) if ( input ) input . focus ( ) }
Open the prompt's dialog.
Open the prompt ' s dialog .