feat(history): /history backend command and status-bar indicator

This commit is contained in:
2026-05-04 17:17:41 +03:00
parent 48b89460b7
commit 16aa569329
4 changed files with 27 additions and 0 deletions

View File

@@ -1146,6 +1146,7 @@ cmd_ac_init(void)
autocomplete_add(history_ac, "on");
autocomplete_add(history_ac, "off");
autocomplete_add(history_ac, "backend");
autocomplete_add(history_ac, "switch");
autocomplete_add(history_ac, "verify");
autocomplete_add(history_ac, "export");

View File

@@ -1882,6 +1882,7 @@ static const struct cmd_t command_defs[] = {
CMD_TAG_CHAT)
CMD_SYN(
"/history on|off",
"/history backend",
"/history switch sqlite|flatfile",
"/history verify [<jid>]",
"/history export [<jid>]",
@@ -1889,12 +1890,14 @@ static const struct cmd_t command_defs[] = {
CMD_DESC(
"Switch chat history on or off, /logging chat will automatically be enabled when this setting is on. "
"When history is enabled, previous messages are shown in chat windows. "
"Use 'backend' to show the active database backend. "
"Use 'switch' to change the active database backend at runtime without reconnecting. "
"Use 'verify' to check integrity of stored message history. "
"Use 'export' to copy messages from SQLite to flat-file format, or 'import' to copy from flat-file to SQLite. "
"Both export and import merge with existing data (duplicates are skipped).")
CMD_ARGS(
{ "on|off", "Enable or disable showing chat history." },
{ "backend", "Show the name of the active database backend." },
{ "switch sqlite|flatfile", "Switch the active database backend at runtime." },
{ "verify [<jid>]", "Verify integrity of message history. Optionally specify a JID to check only one contact." },
{ "export [<jid>]", "Export SQLite history to flat-file format. Optionally specify a JID to export only one contact." },

View File

@@ -6785,6 +6785,15 @@ cmd_history(ProfWin* window, const char* const command, gchar** args)
return TRUE;
}
if (g_strcmp0(args[0], "backend") == 0) {
if (active_db_backend && active_db_backend->name) {
cons_show("Active database backend: %s", active_db_backend->name);
} else {
cons_show("No database backend is currently active.");
}
return TRUE;
}
if (g_strcmp0(args[0], "switch") == 0) {
jabber_conn_status_t conn_status = connection_get_status();
if (conn_status != JABBER_CONNECTED) {

View File

@@ -52,6 +52,7 @@
#include "config/theme.h"
#include "config/preferences.h"
#include "database.h"
#include "ui/ui.h"
#include "ui/statusbar.h"
#include "ui/inputwin.h"
@@ -83,6 +84,7 @@ static WINDOW* statusbar_win;
void _get_range_bounds(int* start, int* end, gboolean is_static);
static int _status_bar_draw_time(int pos);
static int _status_bar_draw_maintext(int pos);
static int _status_bar_draw_dbbackend(int pos);
static int _status_bar_draw_bracket(gboolean current, int pos, const char* ch);
static int _status_bar_draw_extended_tabs(int pos, gboolean prefix, int start, int end, gboolean is_static);
static int _status_bar_draw_tab(StatusBarTab* tab, int pos, int num, gboolean include_brackets);
@@ -313,6 +315,7 @@ status_bar_draw(void)
pos = _status_bar_draw_time(pos);
pos = _status_bar_draw_maintext(pos);
pos = _status_bar_draw_dbbackend(pos);
if (max_tabs != 0)
pos = _status_bar_draw_tabs(pos);
@@ -603,6 +606,17 @@ _status_bar_draw_maintext(int pos)
return pos;
}
static int
_status_bar_draw_dbbackend(int pos)
{
if (!active_db_backend || !active_db_backend->name)
return pos;
auto_gchar gchar* label = g_strdup_printf(" [%s]", active_db_backend->name);
mvwprintw(statusbar_win, 0, pos, "%s", label);
return pos + utf8_display_len(label);
}
static void
_destroy_tab(StatusBarTab* tab)
{