Options
All
  • Public
  • Public/Protected
  • All
Menu

Module prompt

Index

Type Aliases

InputFilter: ((input: string, meta: InputFilterMeta) => boolean)

Type declaration

Variables

history: { add: ((cmd: any) => boolean); clear: (() => void); get: (() => any[]); remove: ((index: number) => boolean); set: ((newHistory: any[]) => void) } = ...

Haven's history API.

Type declaration

  • add: ((cmd: any) => boolean)
      • (cmd: any): boolean
      • Add a command to the command history.

        Parameters

        • cmd: any

        Returns boolean

        True if successful

  • clear: (() => void)
      • (): void
      • Clear the entire command history.

        Returns void

  • get: (() => any[])
      • (): any[]
      • Returns a copy of the entire command history.

        Returns any[]

  • remove: ((index: number) => boolean)
      • (index: number): boolean
      • Remove a single item from the command history.

        Parameters

        • index: number

          The index of the command to remove. If empty, the last command will be removed.

        Returns boolean

        True if removal was successful.

  • set: ((newHistory: any[]) => void)
      • (newHistory: any[]): void
      • Sets a completely new command history.

        Parameters

        • newHistory: any[]

          An array of strings that becomes the new command history.

        Returns void

Functions

  • applyInputFilters(originalInput: string, meta: InputFilterMeta): Promise<string | false>
  • Runs input through all input filters.

    since

    3.2.0

    internal

    Parameters

    • originalInput: string

      The original input

    • meta: InputFilterMeta

      Associated input meta

    Returns Promise<string | false>

  • clearCommandQueue(): void
  • clearKeyQueue(): void
  • hide(): void
  • Manually hide the prompt. It won't be shown until unhide() is called.

    Returns void

  • init(): void
  • queueCommand(cmd: string, silent?: boolean): void
  • Add a command to the command queue. If the line input is ready, execute the command immediately.

    Parameters

    • cmd: string

      Command to add

    • silent: boolean = false

      If true, the command isn't shown on the screen. The result of the command will still print normally.

    Returns void

  • queueKeypress(key: string): void
  • Add a keypress to the command queue. If the engine is waiting for a keypress, send it immediately.

    since

    3.2.0

    Parameters

    • key: string

      A one-character string containing the pressed character

    Returns void

  • Removes a filter from registered input filters.

    since

    3.2.0

    Parameters

    Returns boolean

    Returns true if the filter was removed, false if the filter wasn't registered.

  • setPrefix(prefix: string, isHtml?: boolean): string
  • Set the prefix of the command prompt. The prefix is usually a greater-than character (>) at the start of the command prompt.

    The currently active command prompt is changed, and the new prefix is used for all future command prompts until changed again.

    Note that calling this function directly with JavaScript changes the prompt in the interpreter, but doesn't pass the information to the story file. Therefore checking what the prefix is in the Inform story might not return correct values because the variable that the story uses to track the prefix content hasn't been changed. In most cases it's recommended to use the Vorple extensions/libraries in Inform to change the prefix.

    Parameters

    • prefix: string

      The new prefix

    • isHtml: boolean = false

      If true, the prefix is inserted into the DOM as HTML. Otherwise HTML is escaped and shown as-is.

    Returns string

    Returns the new prefix.

  • setValue(value: string): void
  • Set the lineinput's value.

    Parameters

    • value: string

      The new value

    Returns void

  • submit(command?: null | string, silent?: boolean): void
  • Trigger the submit event of the lineinput.

    Parameters

    • Optional command: null | string

      The command to send, if null or left out the lineinput field's current value is used.

    • silent: boolean = false

      If true, the command isn't shown on the screen. The result of the command will still print normally.

    Returns void

  • unhide(): void
  • Remove manual hiding of the prompt. It's called rather clumsily "unhide" instead of "show" to stress that it only undoes what the hide method did, and it doesn't force the prompt to appear if it has been hidden or removed by some other means.

    Returns void

Generated using TypeDoc