18#include <gdk/gdkkeysyms.h>
46#define MAX_LUACONSOLE_HISTORY 20
74 int response, gpointer data);
130 if (pdialog->
shell == NULL) {
148 if (pdialog->
shell == NULL) {
162 return (NULL != pdialog->
shell);
174 if (NULL != pdialog->
shell) {
184 GtkWidget *
entry, *vgrid, *sw, *text, *notebook;
198 vgrid = gtk_grid_new();
199 gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid),
200 GTK_ORIENTATION_VERTICAL);
203 sw = gtk_scrolled_window_new();
204 gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw),
TRUE);
205 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
206 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
207 gtk_grid_attach(GTK_GRID(vgrid), sw, 0, grid_row++, 1, 1);
210 gtk_widget_set_hexpand(text,
TRUE);
211 gtk_widget_set_vexpand(text,
TRUE);
213 gtk_text_view_set_editable(GTK_TEXT_VIEW(text),
FALSE);
214 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), text);
215 g_signal_connect(text,
"resize",
218 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
219 gtk_widget_realize(text);
220 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 5);
227 entry = gtk_entry_new();
228 gtk_widget_set_margin_bottom(
entry, 2);
229 gtk_widget_set_margin_end(
entry, 2);
230 gtk_widget_set_margin_start(
entry, 2);
231 gtk_widget_set_margin_top(
entry, 2);
232 gtk_grid_attach(GTK_GRID(vgrid),
entry, 0, grid_row++, 1, 1);
235 g_signal_connect(
entry,
"key_press_event",
259 const char *theinput;
261 GtkEntryBuffer *buffer;
266 buffer = gtk_entry_get_buffer(w);
267 theinput = gtk_entry_buffer_get_text(buffer);
285 gtk_entry_buffer_set_text(buffer,
"", -1);
292 int response, gpointer data)
317 filesel = gtk_file_chooser_dialog_new(
"Load Lua file", GTK_WINDOW(
toplevel),
318 GTK_FILE_CHOOSER_ACTION_OPEN,
319 _(
"_Cancel"), GTK_RESPONSE_CANCEL,
320 _(
"_Open"), GTK_RESPONSE_OK,
324 g_signal_connect(filesel,
"response",
328 gtk_window_present(GTK_WINDOW(filesel));
337 if (response == GTK_RESPONSE_OK) {
338 GFile *file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(dlg));
341 gchar *filename = g_file_get_parse_name(file);
343 if (NULL != filename) {
349 g_object_unref(file);
353 gtk_window_destroy(GTK_WINDOW(dlg));
363 GtkEntryBuffer *buffer = gtk_entry_get_buffer(GTK_ENTRY(w));
368 keyval = gdk_key_event_get_keyval(ev);
374 gtk_editable_set_position(GTK_EDITABLE(w), -1);
387 gtk_entry_buffer_set_text(buffer,
"", -1);
389 gtk_editable_set_position(GTK_EDITABLE(w), -1);
407 static int old_width = 0, old_height = 0;
409 if (
width != old_width
410 ||
height != old_height) {
429 if (pdialog->
shell) {
436 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(pdialog->
message_area),
437 &end, 0.0,
TRUE, 1.0, 0.0);
456 if (pdialog->
shell) {
469 const struct text_tag_list *tags)
480 gtk_text_buffer_get_end_iter(buf, &iter);
481 gtk_text_buffer_insert(buf, &iter,
"\n", -1);
482 mark = gtk_text_buffer_create_mark(buf, NULL, &iter,
TRUE);
491 strftime(timebuf,
sizeof(timebuf),
"[%H:%M:%S] ", &now_tm);
492 gtk_text_buffer_insert(buf, &iter, timebuf, -1);
495 text_start_offset = gtk_text_iter_get_offset(&iter);
496 gtk_text_buffer_insert(buf, &iter,
astring, -1);
504 gtk_text_buffer_delete_mark(buf, mark);
struct canvas int int struct sprite int int int int height
struct canvas int int struct sprite int int int width
const struct ft_color ftc_luaconsole_input
#define text_tag_list_iterate_end
#define text_tag_list_iterate(tags, ptag)
bool genlist_remove(struct genlist *pgenlist, const void *punlink)
struct genlist * genlist_new(void)
void * genlist_get(const struct genlist *pgenlist, int idx)
void genlist_prepend(struct genlist *pgenlist, void *data)
void genlist_destroy(struct genlist *pgenlist)
int genlist_size(const struct genlist *pgenlist)
void set_message_buffer_view_link_handlers(GtkWidget *view)
void scroll_if_necessary(GtkTextView *textview, GtkTextMark *scroll_target)
void apply_text_tag(const struct text_tag *ptag, GtkTextBuffer *buf, ft_offset_t text_start_offset, const char *text)
GtkWidget * bottom_notebook
GtkWidget * right_notebook
#define GUI_GTK_OPTION(optname)
void gui_dialog_destroy(struct gui_dialog *dlg)
void gui_dialog_present(struct gui_dialog *dlg)
void gui_dialog_raise(struct gui_dialog *dlg)
void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gpointer user_data, bool check_top)
void gui_dialog_response_set_callback(struct gui_dialog *dlg, GUI_DIALOG_RESPONSE_FUN fun)
GtkWidget * gui_dialog_add_button(struct gui_dialog *dlg, const char *text, int response)
void gui_dialog_show_all(struct gui_dialog *dlg)
void gui_dialog_set_title(struct gui_dialog *dlg, const char *title)
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
#define MAX_LUACONSOLE_HISTORY
void luaconsole_dialog_popdown(void)
static struct luaconsole_data * luaconsole_dialog_get(void)
static void luaconsole_dialog_scroll_to_bottom(void)
void luaconsole_dialog_init(void)
bool luaconsole_dialog_is_open(void)
static void luaconsole_load_file_callback(GtkWidget *widget, gint response, gpointer data)
static void luaconsole_dialog_create(struct luaconsole_data *pdialog)
static void luaconsole_response_callback(struct gui_dialog *pgui_dialog, int response, gpointer data)
static struct luaconsole_data * luaconsole
static void luaconsole_dialog_refresh(struct luaconsole_data *pdialog)
static void luaconsole_dialog_destroy(struct luaconsole_data *pdialog)
static void luaconsole_input_return(GtkEntry *w, gpointer data)
void real_luaconsole_append(const char *astring, const struct text_tag_list *tags)
static void luaconsole_load_file_popup(void)
void real_luaconsole_dialog_update(void)
void luaconsole_dialog_popup(bool raise)
static gboolean luaconsole_input_handler(GtkWidget *w, GdkEventKey *ev)
void luaconsole_dialog_done(void)
void gui_dialog_add_content_widget(struct gui_dialog *dlg, GtkWidget *wdg)
void widget_destroyed(GtkWidget *wdg, void *data)
static void luaconsole_dialog_area_resize(GtkWidget *widget, int width, int height, gpointer data)
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
void luaconsole_welcome_message(void)
void luaconsole_printf(const struct ft_color color, const char *format,...)
#define fc_calloc(n, esz)
bool script_client_do_file(const char *filename)
bool script_client_do_string(const char *str)
struct gui_dialog * shell
struct genlist * history_list
GtkTextView * message_area
GtkTextBuffer * message_buffer
struct tm * fc_localtime(const time_t *timep, struct tm *result)