#!/usr/bin/env perl
use warnings;
use strict;
use 5.010001;

our $VERSION = '2.256';

use Term::Choose::Screen qw( hide_cursor show_cursor clear_to_end_of_screen );

use App::DBBrowser;

binmode STDIN,  ':encoding(utf-8)';
binmode STDOUT, ':encoding(utf-8)';
binmode STDERR, ':encoding(utf-8)';

my $old_out_codepage;

BEGIN {
    print hide_cursor();
    $ENV{TC_RESET_AUTO_UP} = 0;
    if ( $^O eq "MSWin32" ) {
        require Win32::Console;
        require Win32::Console::ANSI;
        $old_out_codepage = Win32::Console::OutputCP();
        Win32::Console::OutputCP( 65001 );
        print "\e(U";
    }
}

END {
    if ( $^O eq "MSWin32" && $old_out_codepage ) {
        Win32::Console::OutputCP( $old_out_codepage );
    }
    delete $ENV{TC_RESET_AUTO_UP};
    print clear_to_end_of_screen();
    print show_cursor();
}


my $db_browser = App::DBBrowser->new();
$db_browser->run();


__END__

=pod

=encoding UTF-8

=head1 NAME

C<db-browser> - Browse C<SQLite>/C<MySQL>/C<PostgreSQL> databases and their tables interactively.

=head1 VERSION

Version 2.256

=head1 SYNOPSIS

=head2 SQLite/MySQL/PostgreSQL

    db-browser -h|--help

    db-browser

    db-browser database-name, ...

When the C<db-browser> is called with the argument C<-h|--help>, it shows a menu. The menu entry I<HELP> shows this
documentation - see L</OPTIONS>.

If C<db-browser> is called without arguments, the user can choose from the databases offered by the database plugin.

If C<db-browser> is called with arguments, the arguments are used as the available databases.

=head2 SQLite

    db-browser -s|--search

C<db-browser> called with C<-s|--search> causes a new search for C<SQLite> databases instead of using the cached data.

=head1 DESCRIPTION

Before using C<db-browser>, make sure you backed up your databases.

Search and read in SQL databases: one can browse databases and their tables interactively.

The database plugins bundled with C<App::DBBrowser> provide support for the DBI drivers C<DBD::SQLite>, C<DBD::mysql>,
C<DBD::MariaDB> and C<DBD::Pg>. See L<App::DBBrowser::DB> how to write a database plugin.

=head1 NAVIGATION

=head2 Menus

=over

=item *

the C<Arrow> keys (or C<h,j,k,l>) to move up and down and to move to the right and to the left.

=item *

the C<PageUp> key (or C<Ctrl-B>) to go back one page, the C<PageDown> key (or C<Ctrl-F>) to go forward one page.

=item *

the C<Home> key (or C<Ctrl-A>) to jump to the beginning of the menu, the C<End> key (or C<Ctrl-E>) to jump to the end
of the menu.

=back

With the option I<mouse> enabled it can be used the mouse with the left mouse key to navigate through the menus.

To confirm a chosen menu item use the C<Return> key.

In some sub-menus it is possible to select more then one item before C<Return> is pressed (e.g. the input filters
I<Choose Rows> and I<Choose Cols>); in such sub-menus the list of items marked with the C<SpaceBar> are added to the
chosen items when C<Return> is pressed. If a mouse mode is enabled, it can be used the right mouse key instead of the
C<SpaceBar>. A C<Ctrl-SpaceBar> inverts the made choices - so for example to select all but one select the one with the
C<SpaceBar> and then press C<Ctrl-SpaceBar>.

=head2 Read-line

=over

=item *

C<BackSpace> or C<Strg-H> to delete the character behind the cursor, C<Delete> to delete  the  character at point.

=item *

C<Strg-U> to delete the text backward from the cursor to the beginning of the line, C<Strg-K> to delete the text from
the cursor to the end of the line.

=item *

C<Right-Arrow> to move forward a character, C<Left-Arrow> to move back a character.

=item *

C<Up-Arrow> to move back 10 characters, C<Down-Arrow> to move forward 10 characters.

=item *

C<Home> or C<Strg-A> to move to the start of the line, C<End> or C<Strg-E> to move to the end of the line.

=back

To leave a C<read-line> without returning anything press C<Ctrl-X>. When the input puffer is empty and an C<Enter> is
pressed, C<read-line> returns an empty string.

=head1 OUTPUT

The elements are right-justified if they look like a number else they are left-justified.

If the option I<squash_spaces> is enabled, leading and trailing spaces are removed from the elements and spaces are
squashed to a single white-space.

Tab characters (C<\t>) are replaces with a space.

Vertical spaces (C<\v>) are squashed to two spaces

Control characters, code points of the surrogate ranges and non-characters are removed.

See also the option group L</Output>.

=head1 MENUS

=head2 Plugins Menu

Choosing a plugin leads to the I<Databases Menu>.

(If there is only one plugin, the plugins menu is not shown but the plugin is chosen automatically.)

=head2 Databases Menu

Choosing a database leads to the I<Schemas Menu>.

(If there is only one database, the databases menu is not shown but the database is chosen automatically.)

=head2 Schemas Menu

Choosing a schema leads to the I<Tables Menu>.

(If there is not more than one schema, the schemas menu is not shown but the schema is chosen automatically.)

=head2 Tables Menu

The menu entries of the tables menu:

=head3 Prompt Line

Selecting the prompt line (the database name) opens a menu with these entries:

=over

=item

Create Table

=item

Drop Table

=item

Create View

=item

Drop View

=item

Attach DB

=item

Detach DB

=back

For I<Create Table>, I<Drop Table>, I<Create View> and I<Drop View> see L</WRITE ACCESS>. These entries are available if
enabled in L</Extensions>.

I<Attache DB> is available for C<SQLite> databases. I<Attach DB> can be used to attach databases to the
current database. The menu entry I<Detach DB> is available if a C<SQLite> database has attached databases.

By selecting the prompt line of this menu (the database name) one can change the I<Source type of input data> settings.

=head3 Tables Entries

Choosing one of the tables leads to the I<SQL Menu>.

=head3 Derived

Choosing this entry allows one to enter a subquery and use it as a table.

This entry is available if enabled in L</Extensions>.

=head3 Join

Join tables.

This entry is available if enabled in L</Extensions>.

=head3 Union

Combine the result from multiple SELECT statements.

This entry is available if enabled in L</Extensions>.

=head3 Settings

See L</DB Settings>.

This entry is available if enabled in L</Extensions>.

=head2 SQL Menu

In this menu it can be formed the SQL query.

The SQL Menu has the following menu entries:

=head3 Prompt Line

Selecting this prompt line (I<Customize:>) opens a menu with these entries:

=over

=item

Insert Into

=item

Update

=item

Delete

=back

See L</WRITE ACCESS>. These entries are available if enabled in L</Extensions>.

By selecting the prompt line of this menu (I<Choose SQL type:>) one can change the I<Source type of input data> settings.

=head3 Print TABLE

Select I<Print TABLE> to show the result of the formed statement on the screen.

=head3 The Sub-Statements Entries

To reset a SQL "sub-statement" (e.g C<WHERE>) re-enter into the respective menu and choose C<-OK->.

See also L</Extensions> and L</Operators>

=head4 SELECT

Choose the required columns for the C<SELECT> sub-statement.

It is possible to ad many columns at once by marking them with the C<SpaceBar> key. If columns are marked with the
C<SpaceBar>, the highlighted column is not added to the chosen when C<Return> is pressed.

If an I<AGGREGATE> function or a I<GROUP BY> columns is selected, the available choices of this sub-statement are the
selected aggregate functions and the selected group-by columns.

=head4 AGGREGATE

C<AVG>, C<COUNT>, C<COUNT(*)>, C<GROUP_CONCAT>/C<STRING_AGG>, C<MAX>, C<MIN>, C<SUM>

=head4 DISTINCT

=head4 WHERE

=head4 GROUP BY

It is possible to ad many columns at once by marking them with the C<SpaceBar> key. If columns are marked with the
C<SpaceBar>, the highlighted column is not added to the chosen when C<Return> is pressed.

=head4 HAVING

=head4 ORDER BY

=head4 LIMIT

=head3 Reset

Reset the SQL statement.

=head1 WRITE ACCESS

=head2 Create/Drop Table/View

I<Create/Drop Table/View> can be reached by selecting the prompt-line in the L</Tables Menu> if the respective option is
activated.

Selecting the prompt line of the I<Create/Drop Table/View> sub-menu allows one to set the parse settings described in
L</Insert Data>.

=head3 Create Table

If the option I<Source type of input data> is set to I<menu>, selecting I<Create Table> opens a sub-menu where one can choose the
type of the data source. If I<Source type of input data> is set to I<plain>, I<copy&paste> or I<file>, the set data source type is
used automatically without showing a menu.

For the meaning of the different data source types see L<Source type of input data>.

After the data has been read the user can apply different input filters (See L<Input filters>). When the input filters
are confirmed the user is asked

=over

=item - for the table name

=item - if the first data row should be used as header

=item - if an auto increment column should be added (if the option L<Auto increment> is enabled)

=item - to edit the column names

=item - to edit the column data types

=item - to confirm the creating of the table

=back

=head3 Drop table

Drop a table. The whole table is shown before the user confirms to drop the table.

=head3 Create View

Before creating a view: print the required select-statement to make it available in the subquery menu.

=head3 Drop View

Drop a view. The whole view is shown before the user confirms to drop the view.

=head2 Insert Into/Update/Delete

I<Insert Into>, I<Update> and I<Delete> can be reached by selecting the prompt-line in the L</SQL Menu> if the
respective option is activated.

I<Delete>, I<Update> or I<Insert Into>  may not be available with C<JOIN> and C<UNION> statements.

Selecting the prompt line of the I<Insert Into/Update/Delete> sub-menu allows one to set the parse settings described in
L</Insert Data>.

=head3 Insert Into

If the option I<Source type of input data> is set to I<menu>, selecting I<Insert Into> opens a sub-menu where one can
choose the type of the data source. If I<Source type of input data> is set to I<plain>, I<copy&paste> or I<file>, the
set data source type is used without showing a menu.

For the meaning of the different data source types see L<Source type of input data>.

After the data has been read the user can apply different input filters (See L<Input filters>).

If the first column of a table is an auto-increment column, the C<INSERT INTO> statement is build without this first
column. This feature is available if supported by the database plugin.

=head3 Update

Update records. The affected (and not yet updated) records are shown shown before the user confirms the update.

See also I<Subqueries> in L</Extensions>

=head3 Delete

Delete records. The affected records are shown before the user confirms the deletion.

=head2 Data Input

=head3 Source type of input data

=over

=item Plain

Insert the data cell by cell.

=item Copy and Paste

Reads from STDIN until the end of input.

=item From File

The data is read from a chosen file.

Supported file formats: text files and file formats supported by L<Spreadsheet::Read>.

Selecting I<From File> opens the I<Source file directory> sub-menu where one can choose the directory which should be
searched for files.

If L<Directory history> is set to C<1> and a directory has been saved, this menu is skipped and the directory is chosen
automatically.

After a directory has been chosen a sub-menu is opened where one can choose the source file.

Selecting the prompt line of the source file sub-menu allows one to set the parse settings described in L</Insert Data>.
If the previous sub-menu I<Source file directory> is not shown due to the settings described before, additionally to the
parse settings it is also possible the change the source file directory in this sub-menu by selecting I<NEW search>.

=back

See also the input filter L</Reparse> in I<Input filters>, which allows one to change the parse-settings and then
re-read the data.

=head3 Input filters

=over

=item Choose Cols

Use only selected columns of the imported data.

If the data has empty columns (C<-->), the non-empty columns are preselected. Columns are regarded as
empty if the values of all fields in the column - including the column header - have no length.

If the selected columns of a previous I<Choose Cols> usage are a subset of the current available columns, this subset
of columns is preselected. A I<RESET> removes this preselection.

Columns added with the filter I<Append Col> are empty and therefore not preselected.

If a column is not empty, but has no header name the header is named temporarily C<tmp>.

=item Choose Rows

Use only selected rows of the imported data.

If the data has empty rows, the non-empty rows are preselected. Rows are regarded as empty if the values of all fields
in the row have no length.

=item Range Rows

Use only a range of rows.

=item Row Groups

If the input has rows with different numbers of columns, I<Row Groups> sorts rows with the same number of columns in a
group. The user can then choose one or more groups of rows. There is only one group, if all rows have the same column
count.

=item Remove Cell

Remove a cell from a chosen row.

=item Insert Cell

Insert a cell in a chosen row. The new cell is inserted in front of a chosen cell.

=item Append Col

Append an empty column. Appends a header element to the header row and adjusts the remaining rows to the length of the
header row. If the input has rows with different numbers of cells, use the I<Row Group> filter first to select the right
row-group.

=item Split Column

     Item | length/width/height             Item | length | width | height
    ------|---------------------            -----|--------|-------|------
      423 |            40/30/25              423 |     40 |    30 |    25
    ------|---------------------              64 |     80 |    60 |    30
       64 |            80/60/30              705 |     50 |    50 |    40
    ------|---------------------
      705 |            50/50/40

=item Search & Replace

     y  | factor                            y  | factor
    ----|---------                          ---|-------
     62 | 8,975.1                           62 | 8975.1
    ----|---------                          63 | 9745.8
     63 | 9,745.8                           64 | 9818.2
    ----|---------
     64 | 9,818.2

In the replacement it can be used the variable C<$c> as a counter. C<$c> is set to C<0> before each C<s///>.

Available modifiers: C<g>, C<i>, C<e>.

By selecting the prompt line (C<Choose:>) one can save search & replace instructions for later use.

If a search & replace has altered the first row of the input data, a menu entry named C<RESTORE header row> is offered.

=item Split Table

     y  | factor  | y  | factor             y  | factor
    ----|---------|----|---------           ---|--------
     62 | 8,975.1 | 64 | 9,986.5            62 | 8,975.1
    ----|---------|----|---------           63 | 9,745.8
     63 | 9,745.8 | 65 | 9,782.7            y  | factor
                                            64 | 9,818.2
                                            65 | 9,986.5

=item Merge Rows

     Month | Average | Average              Month | Average MinTemp | Average MaxTemp
    -------|---------|---------             ------|-----------------|----------------
           | MinTemp | MaxTemp              Jan   |               9 |              22
    -------|---------|---------             Feb   |              10 |              23
     Jan   |       9 |      22
    -------|---------|---------
     Feb   |      10 |      23

I<Merge Rows> can be used to edit a row by selecting only one row.

=item Join Columns

     Item | length | width | height          Item | length/width/height
    ------|--------|-------|--------         -----|-------------------
      423 |     40 |    30 |     25           423 | 40/30/25
    ------|--------|-------|--------           64 | 80/60/30
       64 |     80 |    60 |     30           705 | 50/50/40
    ------|--------|-------|--------
      705 |     50 |    50 |     40

I<Join Columns> can be used to edit a column by selecting only one column.

=item Fill up Rows

If the input table rows have different numbers of cells, this filter appends empty cells to the rows until the cell
count of the rows are equal to the cell count of the row with highest cell count.

One can enter in the I<Row Group> filter to see if the table has rows with different length. If I<Row Group> shows only
one group, all rows have the same length.

=item Cols to Rows

Transpose columns to rows.

     Year | 2000 | 2001 | 2002              Year | Max | Min
    ------|------|------|------             -----|-----|----
     Max  |   14 |   22 |   17              2000 |  14 |  11
    ------|------|------|------             2001 |  22 |  10
     Min  |   11 |   10 |    9              2002 |  17 |   9

=item Empty to NULL

Convert fields containing an empty string to NULL (undefined).

The default values for this filter can be set with the option L<Empty to Null>.

=item Reset

Reset the filters to the default values.

=item Reparse

Change the parse settings and reparse the data with the new settings.

=back

=head1 OPTIONS

The options menu is called with C<db-browser -h>.

=head2 HELP

Show this documentation.

=head2 Path

Shows the version and the path of the running C<db-browser> and the path of the application directory.

=head2 DB Options

=head3 DB Plugins

Choose the required database plugins.

=head3 DB Settings

These driver specific I<DB Settings> are used as the default database settings.

There is also in each L</Tables Menu> the entry I<Settings> (if enabled in L</Extensions>) to make database specific
settings. If no database specific settings are set, these global (to the database plugin) I<DB Settings> are used.

User defined database plugins: it depends on the plugin which items are offered to be set in each option and whether the
selections made by the user are considered.

=over

=item Fields

Set which fields are required to connect to a database.

=item Login Data

The entered login data is saved in a configuration file and used to connect to the database (the password can not be
saved).

=item ENV Variables

The user can choose environment variables form a list of environment variables that should be used - if set - to connect
to the database.

=item Attributes

For the meaning of these driver specific attributes check the appropriate driver documentation.

=item Reset DB

Reset database specific parameter to the global I<DB Settings>.

=back

=head2 Behavior

Set the behavior of the interactive menus.

=head3 Menu memory

If enabled: saves the menu position while entering in a sub menu.

=head3 Keep header

Show the table header on top of each page.

=head3 Expand table

Expand table rows:

=over

=item C<YES>

if C<Return> is pressed, the selected table row is printed with each column in its own line.

=item C<NO>

don't expand table rows.

=item C<YES fast back>

do not expand the first row if the cursor auto-jumped to the first row.

=back

=head3 Expand info table

Before records are deleted/updated and before a table or a view is dropped the affected records are shown in an info-table.

Expand info tables rows:

=over

=item C<YES>

if C<Return> is pressed, the selected table row is printed with each column in its own line.

=item C<NO>

don't expand table rows.

=item C<YES fast back>

do not expand the first row if the cursor auto-jumped to the first row.

=back

=head3 Mouse mode

Set the I<Mouse mode> (see L<Term::Choose/mouse>).

=head2 Extensions

Add menu entries to menus:

=head3 Tables menu

=over

=item

Derived (table)

=item

Join

=item

Union

=item

DB settings

=back

=head3 Join menu

=over

=item

Derived (table)

=back

=head3 Union menu

=over

=item

Derived (table)

=item

Union All

=back

=head3 Substatements

Substatement additions for:

=over

=item SELECT

I<None>, I<Func>, I<SQ>, I<Func/SQ>

=item WHERE

I<None>, I<Func>, I<SQ>, I<Func/SQ>

=item GROUP BY

I<None>, I<Func>, I<SQ>, I<Func/SQ>

=item HAVING

I<None>, I<Func>, I<SQ>, I<Func/SQ>

=item ORDER BY

I<None>, I<Func>, I<SQ>, I<Func/SQ>

=item SET

I<None>, I<Func>, I<SQ>, I<=N>, I<Func/SQ/=N>

=back

If set to I<None>, no menu extensions are available.

If set to I<Func>, C<f()> is shown as additionally menu entry. Selecting C<f()> opens the L</Functions> menu.

If set to I<SQ>, C<SQ> is shown as additionally menu entry. Selecting C<SQ> opens the L</Subqueries> menu.

If set to I<=N>, C<=N> is shown as additionally menu entry (available after the C<SET> in an C<UPDATE> statement).
Selecting C<=N> sets the column to C<NULL>.

If set to I<Func/SQ> (or I<Func/SQ/=N>), C<%%> is shown as additionally menu entry. Selecting C<%%> lets one choose
between all available extensions.

If these menu entries are prefixed with C<=>, it is required to select the wanted operator I<after> the extended menu
entry has been chosen.

=head4 Functions

=over

=item

Bit_Length

=item

Char_Length

=item

Concatenate

=item

Epoch_to_Date

=item

Epoch_to_DateTime

=item

Replace

=item

Round

=item

Truncate

=back

=head4 Subqueries

Selecting a subquery menu entry (or a I<Derived> menu entry) opens a subquery sub-menu which allows one the enter a
subquery (I<Read-Line>).

If stored or temporarily stored subqueries are available, it is also possible to select one of those subqueries instead
of entering a subquery.

The subqueries are automatically enclosed in parentheses if the subqueries do not contain any parentheses.

A subquery can be saved or removed in the sub-menu which opens by selecting the prompt line of a subquery menu
(I<Choose SQ:>).

The last subqueries entered in the subquery menu and the last statements printed with I<Print TABLE> are stored
temporarily.

=head3 Parentheses

Enable parentheses in C<WHERE> and/or C<HAVING> clauses.

=head3 Write access

Enable write access - use with care.

=over

=item

Insert Records

=item

Update Records

=item

Delete Records

=item

Create Table

=item

Drop Table

=item

Create View

=item

Drop View

=back

=head2 SQL

=head3 Metadata

If I<Metadata> is enabled, system tables/schemas/databases are appended to the respective list.

=head3 Operators

Choose the required operators.

There are two regexp entries: C<REGEXP> matches case sensitive while C<REGEXP_i> matches case insensitive.

With C<MySQL> the sensitive match is achieved by enabling the C<BINARY> operator.

=head3 Aliases

If enabled, it is asked for an alias. If entered nothing, no alias is added except for joined tables and unions and for
derived tables which get then a default alias.

=over

=item

Aggregate

=item

Derived tables

=item

Functions in the SELECT sub-statement.

=item

Join

=item

Subqueries in the SELECT sub-statement.

=item

Union

=back

=head3 Identifiers

=over

=item Qualified table names

If set to C<YES>, qualified table names are used in SQL statements.

=item Quote identifiers

If set to C<YES>, SQL identifiers are quoted.

=back

C<SQLite>:

- databases in SQL statements (C<ATTACH DATABASE>) are always quoted.

- if the current database has attached databases, the use of qualified table names is enabled automatically.

=head3 View prefix

Enter a string which should be automatically put in front of all view names.

=head3 Auto increment

Setting I<Auto increment> to a value which is not the empty string enables the option to set an auto increment column
when creating a table. The value set here is then used as the default name for the auto increment column.

=head3 Col data types

If this option is enabled and a table is created, C<SQL::Type::Guess> is used to detect the data types. These data types
are then used as default values when the user is asked for the data types.

=head3 Max Rows

Sets C<LIMIT> automatically to I<Max Rows>. This can be overwritten by setting a SQL C<LIMIT> statement manually.
Fetched table rows are kept in memory.

To disable the automatic limit set I<Auto Limit> to C<0>.

=head2 Output

=head3 Col width

Columns with a width below or equal I<Colwidth> are only trimmed if it is still required to lower the row width despite
all columns wider than I<Colwidth> have been trimmed to I<Colwidth>.

=head3 Progress bar

Set the progress bar threshold. If the number of fields (rows x columns) is higher than the threshold, a progress bar is
shown while preparing the data for the output.

=head3 Tab width

Set the number of spaces between columns.

=head3 Grid

Separate the columns from each other and the header from the body with lines.

=head3 Color

Enables the support for color and text formatting escape sequences (SGR) if set to C<Enable>. Before the output it is
added a reset (C<\e[0m>) at the end of each row.

=head3 Binary binary

Setting the I<binary_filter> to C<1> means: print "BNRY" instead of arbitrary binary data. If data matches the repexp
C</[\x00-\x08\x0B-\x0C\x0E-\x1F]/>, it is considered arbitrary binary data. Printing arbitrary binary data could break
the output.

=head3 Squash spaces

If I<squash_spaces> is enabled, consecutive spaces are squashed to one space and leading and trailing spaces are removed.

=head3 Show table name

If enabled, the table name is displayed in the lower left corner of the terminal behind the page number.

=head3 Indentation

Set the indentation width for the info output.

=head3 Truncated rows

How should truncated data source rows be marked at the end: C<...>, C<|> or C<none>.

=head3 Set string

=head4 Undef

Set the string that will be shown on the screen instead of an undefined field.

On C<MSWin32> only single-byte character sets are supported when entering the setting I<Undef>, I<user>, I<host> or
I<port> with the C<db-browser>s readline. But it is possible to edit the entry in configuration files directly after the
entry was created with this options menu.

=head4 Decimal separator

Set the decimal separator. Numbers with a decimal separator are formatted as number if this option is set to the right
value.

Allowed values: a character with a print width of C<1>. If an invalid value is passed, I<decimal_separator> falls back
to the default value (dot).

=head3 Warnings

Enable/disable C<File::Find> warnings when searching for C<SQLite> databases.

=head2 Insert Data

=head3 Parse tool for 'file'

Set how to parse text files. Files where C<-T $filename> returns true are considered text files.

If a file is not a text file, then it is always used C<Spreadsheet::Read> to parse the file regardless of this setting.

=over

=item

Text::CSV

To decode the files it is used the L</File encoding>.

Advantages:

=over

=item

Allows to set different csv-related options.

=back

=back

=over

=item

split

Reads to whole input at once and splits the input with the input record separator (IRS) to get the records (rows). Then
it splits the records with the input field separator (IFS) to get the fields (columns) of each record.

To decode the files it is used the L</File encoding>.

Advantages:

=over

=item

The values assigned to the IRS and the IFS are treated as regexps.

=back

=back

=over

=item

Template

Uses C<unpack> with the C<A> character to break up input lines.

C<unpack> used with C<A> strips trailing whitespace. For leading whitespace to user has the option to remove it or not.
Any remaining column separators can be removed with the I<Search & Replace> filter.

If the row length is greater than the screen width, make notes of the number of columns and the length of each column
before using I<Template>.

Advantages:

=over

=item

Good for input with fixed-columns-length.

=back

=back

=over

=item

Spreadsheet::Read

If C<Spreadsheet::Read> is chosen, the default settings from L<Spreadsheet::Read> are used.

C<Spreadsheet::Read> will use the first line of the file to auto-detect the separation character if the file is a
csv-file.

C<Spreadsheet::Read::rows> fills up uneven rows automatically so the filter L<Fill up Rows> and L<Row Groups> have no
meaning if C<Spreadsheet::Read> is used.

Advantages:

=over

=item

Auto-detects the separation character for csv-files

=back

=back

=head3 Parse tool for 'copy & paste'

Set how to parse the "multi row" input.

Same options as in I<Parse file>.

=head3 csv settings-a

Set the Text::CSV options

=over

=item

sep_char

=item

quote_char

=item

escape_char

=item

eol

=back

=head3 csv settings-b

Set Text::CSV options not mentioned in I<csv settings-a>:

For the meaning of the different options see L<Text::CSV>.

=head3 'split' settings

=over

=item

Record separator

Set the input record separator (regexp).

=item

Trim record left

Expects a regex pattern. If set, removes leading characters matching regexp from each record.

=item

Trim record right

Expects a regex pattern. If set, removes trailing characters matching regexp from each record.

=item

Field separator

Set the input field separator (regexp).

=item

Trim field left

Expects a regex pattern. If set, removes leading characters matching regexp from each field.

=item

Trim field right

Expects a regex pattern. If set, removes trailing characters matching regexp from each field.

=back

=head3 Enable input filter

Enable the input filter menu.

=head3 Empty to Null

Set the I<empty_to_null> defaults for the different data source types.

=head3 File encoding

How to decode text files.

=head3 Source type of input data

Set the data source type to C<plain>, C<copy&paste>, C<file> or C<menu> for C<Insert Into> and for
C<Create Table>.

If this option is set to C<menu>, a menu is offered where the user can choose the type of the data source.

=head3 Directory history

Set how many searched directories should be saved in the directory history.

A value of C<0> disables the history.

If I<Directory history> is set to C<1> and a directory has been saved, the directory is chosen automatically without
showing the history menu.

=head3 File filter

This option expects as its value a string. The string is used as a glob pattern.

If I<file> is selected as the data source type, only files matching this glob pattern are part of the available files.

=head3 Show hidden files

If I<file> is selected as the data source type, this setting determines if hidden files are part of the available files
or not.

=head1 CONFIGURATION FILES

To find out the location of the configuration files call C<db-browser -h> and choose I<Path>. The data is saved in JSON
format.

=head1 REQUIREMENTS

=head2 Perl version

Requires Perl version 5.10.1 or greater.

=head2 Decoded strings

C<db-browser> expects decoded strings.

Non mappable characters will break the output.

=head2 Terminal

It is required a terminal that uses a monospaced font which supports the printed characters.

The terminal has to understand ANSI escape sequences. If the OS is MSWin32 C<App::DBBrowser> uses
L<Win32::Console::ANSI> which emulates an ANSI console for the C<db-browser>.

=head2 Permissions

To be able to browse the database-, schema- and table-lists and the content of tables the user must have the database
privileges required for fetching the requested data.

The C<db-browser> expects an existing home directory with read and write permissions for the user of the C<db-browser>.

=head1 CREDITS

Thanks to the L<Perl-Community.de|http://www.perl-community.de> and the people form
L<stackoverflow|http://stackoverflow.com> for the help.

=head1 AUTHOR

Matthäus Kiem <cuer2s@gmail.com>

=head1 LICENSE AND COPYRIGHT

Copyright 2012-2021 Matthäus Kiem.

THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE
IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5.10.0. For
details, see the full text of the licenses in the file LICENSE.

=cut