File awful/prompt.lua

Author:

Julien Danjou <julien@danjou.info>

Copyright ©2008 Julien Danjou

Release: v3.1.2

Functions

history_add (id, command) Add an entry to the history file
history_check_load (id, max) Load history file in history table
history_items (id) Return the number of items in history table regarding the id
history_save (id) Save history table in history file
prompt_text_with_cursor (text, text_color, cursor_color, cursor_pos, cursor_ul) Draw the prompt text with a cursor.
run (args, textbox, exe_callback, completion_callback, history_path, history_max, done_callback) Run a prompt in a box.


Functions

history_add (id, command)
Add an entry to the history file

Parameters

  • id: The data.history identifier
  • command: The command to add
history_check_load (id, max)
Load history file in history table

Parameters

  • id: The data.history identifier which is the path to the filename
  • max: Optional parameter, the maximum number of entries in file
history_items (id)
Return the number of items in history table regarding the id

Parameters

  • id: The data.history identifier

Return value:

the number of items in history table, -1 if history is disabled
history_save (id)
Save history table in history file

Parameters

  • id: The data.history identifier
prompt_text_with_cursor (text, text_color, cursor_color, cursor_pos, cursor_ul)
Draw the prompt text with a cursor.

Parameters

  • text: The text.
  • text_color: The text color.
  • cursor_color: The cursor color.
  • cursor_pos: The cursor underline style.
  • cursor_ul:
run (args, textbox, exe_callback, completion_callback, history_path, history_max, done_callback)
Run a prompt in a box.

Parameters

  • args: A table with optional arguments: fg_cursor, bg_cursor, ul_cursor, prompt, text, selectall .
  • textbox: The textbox to use for the prompt.
  • exe_callback: The callback function to call with command as argument when finished.
  • completion_callback: The callback function to call to get completion.
  • history_path: Optional parameter: file path where the history should be saved, set nil to disable history
  • history_max: Optional parameter: set the maximum entries in history file, 50 by default
  • done_callback: Optional parameter: the callback function to always call without arguments, regardless of whether the prompt was cancelled.

Valid XHTML 1.0!