| | |
- db_navigator(stdscr, db)
- Navigates through the database options using a curses-based interface.
The function initializes the curses environment, sets up color pairs, and defines a menu with various database options.
It then enters a main loop where it displays the main screen layout, handles user input to navigate through the menu,
and calls the corresponding display functions based on the selected menu option.
Args:
stdscr: The curses window object.
db: The database connection object.
Menu Options:
- "DB Info": Displays database information.
- "View Tables": Displays the list of tables.
- "View Views": Displays the list of views.
- "View Materialized Views": Displays the list of materialized views.
- "View Stored Procedures": Displays the list of stored procedures.
- "View Trigger Functions": Displays the list of trigger functions.
User Input:
- 'q': Quit the navigator.
- KEY_UP: Move the selection up.
- KEY_DOWN: Move the selection down.
- KEY_ENTER, 10, 13, KEY_RIGHT: Select the current menu option and display the corresponding information.
- display_db_info(stdscr, db, info_offset)
- Displays the database information on the provided screen.
Args:
stdscr: The curses window object where the information will be displayed.
db: The database object containing the information to be displayed.
info_offset: The vertical offset to display the database information.
- display_function(stdscr, function, function_name, func_offset)
- Displays the trigger function information on the provided screen.
Args:
stdscr: The curses window object where the information will be displayed.
function: The trigger function code to be displayed.
function_name: The name of the trigger function.
func_offset: The vertical offset to display the trigger function information.
- display_help(stdscr)
- Display help information.
- display_info(stdscr, db)
- Displays the database navigator information on the provided screen.
Args:
stdscr: The curses window object where the information will be displayed.
db: The database object containing the name attribute to be displayed.
- display_main_screen(stdscr, menu_list, selected_row_idx, info_offset)
- Displays the main screen layout with the menu options and highlights the selected row.
Args:
stdscr: The curses window object where the main screen layout will be displayed.
menu_list: A list of menu options to display.
selected_row_idx: The index of the selected row in the menu list.
info_offset: The vertical offset to display the menu options.
- display_mv_view(stdscr, table, view_name, query, view_offset)
- Displays the materialized view information and records on the provided screen.
Args:
stdscr: The curses window object where the information will be displayed.
table: The table object containing the records to be displayed.
view_name: The name of the materialized view.
query: The query used to create the materialized view.
view_offset: The vertical offset to display the materialized view information.
- display_mv_views(stdscr, db, info_offset)
- Displays the list of materialized views in the database on the provided screen.
Args:
stdscr: The curses window object where the information will be displayed.
db: The database object containing the information to be displayed.
info_offset: The vertical offset to display the database information
- display_popup(stdscr, message: str, timeout: int = 0)
- Display a centered popup message.
- display_procedure(stdscr, procedure, procedure_name, proc_offset)
- Displays the stored procedure information on the provided screen.
Args:
stdscr: The curses window object where the information will be displayed.
procedure: The stored procedure code to be displayed.
procedure_name: The name of the stored procedure.
proc_offset: The vertical offset to display the stored procedure information
- display_stored_procedures(stdscr, db, info_offset)
- Displays the list of stored procedures in the database on the provided screen.
Args:
stdscr: The curses window object where the information will be displayed.
db: The database object containing the information to be displayed.
info_offset: The vertical offset to display the database information.
- display_table(stdscr, table, table_name, tables_offset)
- Displays the table information and records on the provided screen.
Args:
stdscr: The curses window object where the information will be displayed.
table: The table object containing the records to be displayed.
table_name: The name of the table.
tables_offset: The vertical offset to display the table information.
- display_tables(stdscr, db, info_offset)
- Displays the list of tables in the database on the provided screen.
Args:
stdscr: The curses window object where the information will be displayed.
db: The database object containing the information to be displayed.
info_offset: The vertical offset to display the database information.
- display_trigger_functions(stdscr, db, info_offset)
- Displays the list of trigger functions in the database on the provided screen.
Args:
stdscr: The curses window object where the information will be displayed.
db: The database object containing the information to be displayed.
info_offset: The vertical offset to display the database information.
- display_view(stdscr, table, view_name, query, view_offset)
- Displays the view information and records on the provided screen.
Args:
stdscr: The curses window object where the information will be displayed.
table: The table object containing the records to be displayed.
view_name: The name of the view.
query: The query used to create the view.
view_offset: The vertical offset to display the view information.
- display_views(stdscr, db, info_offset)
- Displays the list of views in the database on the provided screen.
Args:
stdscr: The curses window object where the information will be displayed.
db: The database object containing the information to be displayed.
info_offset: The vertical offset to display the database information.
- is_key(key, key_type)
- Check if the input key matches any of the mapped keys for the given key type.
Args:
key: The input key code
key_type: The type of key to check ('UP', 'DOWN', 'LEFT', 'RIGHT', 'ENTER', 'QUIT')
bool: True if the key matches any of the mapped keys, False otherwise
Returns:
- remove_leading_spaces(code: str) -> str
- Remove leading spaces from each line of the given code.
- safe_addstr(stdscr, y: int, x: int, text: str, attr=None)
- Safely add a string to the screen, handling boundary errors.
- safe_execution(func)
- Decorator to handle exceptions and log errors for functions.
- search_prompt(stdscr, items: List[str]) -> Optional[int]
- Display search prompt and return index of matched item.
|