Prints a backtrace.
Use only for temporary debugging i.e. not in code in the repository
-```text
-When the LogWindow has focus, the F1 key executes the following action as a command line program:
-<options->log_window.action> <selected text>
-The log_window.action value must be set by editing the geeqierc.xml file manually.
-If no text is selected when the F1 key is pressed, the text either side of the cursor delimited by a space character or the beginning or end of the line is selected.
-This feature may be used to open an editor at a file location listed in the backtrace.
-```
-
### DEBUG_FD()
Prints a dump of the FileData hash list as a ref. count followed by the full path of the item.
Use only for temporary debugging i.e. not in code in the repository
+### Log Window
+
+When the Log Window has focus, the F1 key executes the action specified in `Edit/Preferences/Behavior/Log Window F1 Command` with the selected text as a parameter.
+If no text is selected, the entire line is passed to the command.
+This feature may be used to open an editor at a file location in the text string.
+
---
## GPL header
g_free(buf);
}
-void log_domain_print_debug(const gchar *domain, const gchar *file_name, const gchar *function_name,
- int line_number, const gchar *format, ...)
+void log_domain_print_debug(const gchar *domain, const gchar *file_name, int line_number, const gchar *function_name, const gchar *format, ...)
{
va_list ap;
gchar *message;
if (options && options->log_window.timer_data)
{
- location = g_strdup_printf("%s:%s:%s:%d:", get_exec_time(), file_name,
- function_name, line_number);
+ location = g_strdup_printf("%s:%s:%d:%s:", get_exec_time(), file_name, line_number, function_name);
}
else
{
- location = g_strdup_printf("%s:%s:%d:", file_name, function_name, line_number);
+ location = g_strdup_printf("%s:%d:%s:", file_name, line_number, function_name);
}
buf = g_strconcat(location, message, NULL);
* Format printed is: \n
* <full path to source file>:<line number>
*
- * The log window F1 command and options->log_window.action may be used
- * to open an editor at a backtrace location.
+ * The log window F1 command and Edit/Preferences/Behavior/Log Window F1
+ * Command may be used to open an editor at a backtrace location.
*/
-void log_print_backtrace(const gchar *file, const gchar *function, gint line)
+void log_print_backtrace(const gchar *file, gint line, const gchar *function)
{
FILE *fp;
char **bt_syms;
}
}
#else
-void log_print_backtrace(const gchar *, const gchar *, gint)
+void log_print_backtrace(const gchar *, gint, const gchar *)
{
}
#endif
#define DOMAIN_INFO "info"
void log_domain_printf(const gchar *domain, const gchar *format, ...) G_GNUC_PRINTF(2, 3);
-void log_domain_print_debug(const gchar *domain, const gchar *file_name, const gchar *function_name,
- int line_number, const gchar *format, ...) G_GNUC_PRINTF(5, 6);
-void log_print_file_data_dump(const gchar *file, const gchar *function_name, gint line_number);
-void log_print_backtrace(const gchar *file, const gchar *function_name, gint line_number);
+void log_domain_print_debug(const gchar *domain, const gchar *file_name, int line_number, const gchar *function_name, const gchar *format, ...) G_GNUC_PRINTF(5, 6);
+void log_print_file_data_dump(const gchar *file, gint line_number, const gchar *function_name);
+void log_print_backtrace(const gchar *file, gint line_number, const gchar *function_name);
#define log_printf(...) log_domain_printf(DOMAIN_INFO, __VA_ARGS__)
{ \
if (debug_level != 1) \
{ \
- log_domain_print_debug(DOMAIN_DEBUG, __FILE__, __func__, __LINE__, __VA_ARGS__); \
+ log_domain_print_debug(DOMAIN_DEBUG, __FILE__, __LINE__, __func__, __VA_ARGS__);\
} \
else \
{ \
#define DEBUG_BT() do \
{ \
- log_print_backtrace(__FILE__, __func__, __LINE__); \
+ log_print_backtrace(__FILE__, __LINE__, __func__); \
} while(0)
#define DEBUG_FD() do \
{ \
- log_print_file_data_dump(__FILE__, __func__, __LINE__); \
+ log_print_file_data_dump(__FILE__, __LINE__, __func__);\
} while(0)
#else /* DEBUG */
{
}
-static gboolean iter_char_search_cb(gunichar ch, gpointer data)
-{
- gboolean ret;
-
- if (ch == GPOINTER_TO_UINT(data))
- {
- ret = TRUE;
- }
- else
- {
- ret = FALSE;
- }
-
- return ret;
-}
-
/**
* @brief Handle escape and F1 keys
* @param UNUSED
* @returns
*
* If escape key pressed, hide log window. \n
- * If no text selected, form a selection bounded by space characters or
- * start and end of line. \n
+ * If no text selected, select the entire line. \n
* If F1 pressed, execute command line program: \n
* <options->log_window.action> <selected text>
*
*/
static gboolean key_pressed(GtkWidget *, GdkEventKey *event, LogWindow *logwin)
{
+ gchar *cmd_line;
+ gchar *sel_text;
GtkTextBuffer *buffer;
GtkTextIter chr_end;
+ GtkTextIter chr_marker;
GtkTextIter chr_start;
GtkTextIter cursor_iter;
GtkTextIter line_end;
GtkTextIter line_start;
GtkTextMark *cursor_mark;
- gchar *cmd_line;
- gchar *sel_text;
if (event && event->keyval == GDK_KEY_Escape)
gtk_widget_hide(logwin->window);
gtk_text_iter_set_line_offset(&line_start, 0);
line_end = cursor_iter;
gtk_text_iter_forward_to_line_end(&line_end);
-
- chr_start = cursor_iter;
- gtk_text_iter_backward_find_char(&chr_start, static_cast<GtkTextCharPredicate>(iter_char_search_cb), GUINT_TO_POINTER(' '), &line_start);
-
- chr_end = cursor_iter;
- gtk_text_iter_forward_find_char(&chr_end, static_cast<GtkTextCharPredicate>(iter_char_search_cb), GUINT_TO_POINTER(' '), &line_end);
-
- gtk_text_buffer_select_range(buffer, &chr_start, &chr_end);
+ chr_marker = line_end;
+ gtk_text_buffer_select_range(buffer, &line_start, &line_end);
}
if (gtk_text_buffer_get_selection_bounds(gtk_text_view_get_buffer(GTK_TEXT_VIEW(logwin->text)), &chr_start, &chr_end))
{
sel_text = gtk_text_buffer_get_text( gtk_text_view_get_buffer(GTK_TEXT_VIEW(logwin->text)), &chr_start, &chr_end, FALSE);
- cmd_line = g_strconcat(options->log_window.action, " ", sel_text, NULL);
+ cmd_line = g_strconcat(options->log_window.action, " \"", sel_text, "\"", NULL);
runcmd(cmd_line);
options->log_window.line_wrap = FALSE;
options->log_window.paused = FALSE;
options->log_window.timer_data = FALSE;
- options->log_window.action = g_strdup("");
+ options->log_window.action = g_strdup("echo");
options->read_metadata_in_idle = FALSE;
options->star_rating.star = STAR_RATING_STAR;
static GtkWidget *sidecar_ext_entry;
static GtkWidget *help_search_engine_entry;
+static GtkWidget *log_window_f1_entry;
+
#define CONFIG_WINDOW_DEF_WIDTH 700
#define CONFIG_WINDOW_DEF_HEIGHT 600
#ifdef DEBUG
set_debug_level(debug_c);
+ config_entry_to_option(log_window_f1_entry, &options->log_window.action, nullptr);
#endif
#ifdef HAVE_LCMS
pref_spin_new_int(group, _("Log Window max. lines:"), nullptr,
1, 99999, 1, options->log_window_lines, &options->log_window_lines);
+
+ hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
+ pref_label_new(hbox, _("Log Window F1 command: "));
+ log_window_f1_entry = gtk_entry_new();
+ gq_gtk_entry_set_text(GTK_ENTRY(log_window_f1_entry), options->log_window.action);
+ gq_gtk_box_pack_start(GTK_BOX(hbox), log_window_f1_entry, FALSE, FALSE, 0);
+ gtk_entry_set_width_chars(GTK_ENTRY(log_window_f1_entry), 15);
+ gtk_widget_show(log_window_f1_entry);
#endif
}