# A Tk console widget for SQLite. Invoke sqlitecon::create with a window name,
# a prompt string, a title to set a new top-level window, and the SQLite
# database handle. For example:
#
# sqlitecon::create .sqlcon {sql:- } {SQL Console} db
#
# A toplevel window is created that allows you to type in SQL commands to
# be processed on the spot.
#
# A limited set of dot-commands are supported:
#
# .table
# .schema ?TABLE?
# .mode list|column|multicolumn|line
# .exit
#
# In addition, a new SQL function named "edit()" is created. This function
# takes a single text argument and returns a text result. Whenever the
# the function is called, it pops up a new toplevel window containing a
# text editor screen initialized to the argument. When the "OK" button
# is pressed, whatever revised text is in the text editor is returned as
# the result of the edit() function. This allows text fields of SQL tables
# to be edited quickly and easily as follows:
#
# UPDATE table1 SET dscr = edit(dscr) WHERE rowid=15;
#
# Create a namespace to work in
#
# Create a console widget named $w. The prompt string is $prompt.
# The title at the top of the window is $title. The database connection
# object is $db
#
# This routine creates a console as a child window within a larger
# window. It also creates an edit menu named "$editmenu" if $editmenu!="".
# The calling function is responsible for posting the edit menu.
#
bind Sqlitecon <1>
bind Sqlitecon <B1-Motion>
bind Sqlitecon <B1-Leave>
bind Sqlitecon <B1-Enter>
bind Sqlitecon <ButtonRelease-1>
bind Sqlitecon <KeyPress>
bind Sqlitecon <Left>
bind Sqlitecon <Control-b>
bind Sqlitecon <Right>
bind Sqlitecon <Control-f>
bind Sqlitecon <BackSpace>
bind Sqlitecon <Control-h>
bind Sqlitecon <Delete>
bind Sqlitecon <Control-d>
bind Sqlitecon <Home>
bind Sqlitecon <Control-a>
bind Sqlitecon <End>
bind Sqlitecon <Control-e>
bind Sqlitecon <Return>
bind Sqlitecon <KP_Enter>
bind Sqlitecon <Up>
bind Sqlitecon <Control-p>
bind Sqlitecon <Down>
bind Sqlitecon <Control-n>
bind Sqlitecon <Control-k>
bind Sqlitecon <<Cut>>
bind Sqlitecon <<Copy>>
bind Sqlitecon <<Paste>>
bind Sqlitecon <<Clear>>
# Insert a single character at the insertion cursor
#
# Move the cursor one character to the left
#
# Erase the character to the left of the cursor
#
# Erase to the end of the line
#
# Move the cursor one character to the right
#
# Erase the character to the right of the cursor
#
w
# Move the cursor to the beginning of the current line
#
w
# Move the cursor to the end of the current line
#
w
# Add a line to the history
#
# Called when "Enter" is pressed. Do something with the line
# of text that was entered.
#
w
# Execute a single SQL command. Pay special attention to control
# directives that begin with "."
#
# The return value is the text output from the command, properly
# formatted.
#
# Change the line to the previous line
#
w
# Change the line to the next line
#
w
# Change the contents of the entry line
#
# Called when the mouse button is pressed at position $x,$y on
# the console widget.
#
# Find the boundry between characters that is nearest
# to $x,$y
#
# This routine extends the selection to the point specified by $x,$y
#
# Called whenever the mouse moves while button-1 is held down.
#
# Called whenever the mouse leaves the boundries of the widget
# while button 1 is held down.
#
# This routine is called to automatically scroll the window when
# the mouse drags offscreen.
#
w
# This routine cancels the scrolling motor if it is active
#
w
# Do a Copy operation on the stuff currently selected.
#
w
# Return 1 if the selection exists and is contained
# entirely on the input line. Return 2 if the selection
# exists but is not entirely on the input line. Return 0
# if the selection does not exist.
#
w
# Do a Cut operation if possible. Cuts are only allowed
# if the current selection is entirely contained on the
# current input line.
#
w
# Do a paste opeation.
#
w
# Enable or disable entries in the Edit menu
#
w
# Prompt the user for the name of a writable file. Then write the
# entire contents of the console screen to that file.
#
w
# Erase everything from the console above the insertion line.
#
w
# An in-line editor for SQL
#