libchimara_la_LIBADD = @CHIMARA_LIBS@
libchimara_la_LDFLAGS = -version-info $(LT_VERSION_INFO) \
-no-undefined \
- -export-symbols-regex "^(glk|chimara|glkunix|giblorb|gidispatch|garglk)_"
+ -export-symbols-regex "^(glk|chimara|glkunix|giblorb|gidispatch)_"
libchimara_includedir = $(includedir)/chimara/libchimara
libchimara_include_HEADERS = \
chimara-glk.h \
#include <libchimara/glk.h>
+#include "chimara-glk-private.h"
+
+extern GPrivate *glk_data_key;
+
+void
+apply_reverse_color(GtkTextTag *tag, gpointer data)
+{
+ g_object_set_data( G_OBJECT(tag), "reverse_color", data );
+}
void
garglk_set_reversevideo(glui32 reverse)
{
+ printf("set_reversevideo(%d)\n", reverse);
+ ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
+ g_return_if_fail(glk_data->current_stream != NULL);
+ g_return_if_fail(glk_data->current_stream->window != NULL);
+
+ GtkTextTagTable *tags = gtk_text_buffer_get_tag_table( GTK_TEXT_BUFFER(glk_data->current_stream->window->widget) );
+ gtk_text_tag_table_foreach( tags, apply_reverse_color, GINT_TO_POINTER(reverse) );
}
+
extern void garglk_set_reversevideo(glui32 reverse);
-#endif /* __GARGLK_H__ */
\ No newline at end of file
+#endif /* __GARGLK_H__ */
gtk_text_buffer_apply_tag_by_name(buffer, "uneditable", &start_iter, &end_iter);
/* Insert pre-entered text if needed */
- if(insert)
+ if(insert) {
gtk_text_buffer_insert(buffer, &end_iter, inserttext, -1);
+ gtk_text_buffer_get_end_iter(buffer, &end_iter); /* update after text insertion */
+ }
/* Scroll to input point */
gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(win->widget), input_position);
+
+ /* Apply the correct style to the input prompt */
+ GtkTextIter input_iter;
+ gtk_text_buffer_get_iter_at_mark(buffer, &input_iter, input_position);
+ gtk_text_buffer_apply_tag_by_name(buffer, "input", &input_iter, &end_iter);
gtk_text_view_set_editable(GTK_TEXT_VIEW(win->widget), TRUE);
g_signal_handler_unblock(buffer, win->insert_text_handler);
void
after_window_insert_text(GtkTextBuffer *textbuffer, GtkTextIter *location, gchar *text, gint len, winid_t win)
{
+ GtkTextBuffer *window_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(win->widget) );
+
/* Set the history position to NULL and erase the text we were already editing */
if(win->history_pos != NULL)
{
if( strchr(text, '\n') != NULL )
{
/* Remove signal handlers */
- GtkTextBuffer *window_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(win->widget) );
g_signal_handler_block(window_buffer, win->insert_text_handler);
/* Make the window uneditable again and retrieve the text that was input */
ChimaraGlk *glk = CHIMARA_GLK(gtk_widget_get_ancestor(win->widget, CHIMARA_TYPE_GLK));
event_throw(glk, evtype_LineInput, win, chars_written, 0);
}
+
+ /* Apply the 'input' style to the text that was entered */
+ GtkTextIter end_iter;
+ gtk_text_buffer_get_end_iter(window_buffer, &end_iter);
+ GtkTextIter input_iter;
+ GtkTextMark *input_position = gtk_text_buffer_get_mark(window_buffer, "input_position");
+ gtk_text_buffer_get_iter_at_mark(window_buffer, &input_iter, input_position);
+ gtk_text_buffer_apply_tag_by_name(window_buffer, "input", &input_iter, &end_iter);
}
/* Internal function: Callback for signal activate on the line input GtkEntry
_COPY_FLAG (language_set);
#undef _COPY_FLAG
+ /* Copy the reverse_color attribute, that was added manually */
+ g_object_set_data( G_OBJECT(copy), "reverse_color", g_object_get_data(G_OBJECT(tag), "reverse_color") );
+
return copy;
}
-
+
/* Internal function that reads the default styles from a CSS file */
void
style_init()
ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
GObject *tag_object = G_OBJECT(tag);
- gint reverse_color = 0;
- /* FIXME where should we keep track of this?
- g_object_get(tag, "reverse_color", &reverse_color, NULL);
- */
+ gint reverse_color = GPOINTER_TO_INT( g_object_get_data(tag_object, "reverse-color") );
int i = 0;
gchar color[20];
g_object_set(tag_object, "background-gdk", foreground_color, NULL);
else
g_object_set(tag_object, "background", "#000000", NULL);
+
+ g_object_set_data( tag_object, "reverse-color", GINT_TO_POINTER(val != 0) );
}
break;
break;
case stylehint_ReverseColor:
- /* FIXME: implement this */
- return 0;
+ return GPOINTER_TO_INT( g_object_get_data(G_OBJECT(tag), "reverse_color") );
break;
default: