Some highlighting stuff again; removed libtool for now

master
Yevgen Muntyan 2005-11-22 18:39:05 +00:00
parent d73b3a15d2
commit 0b5a06a28b
15 changed files with 493 additions and 446 deletions

View File

@ -1,11 +1,6 @@
EXTRA_DIST = mingw-configure cygwin-configure
DIST_SUBDIRS = tests m4
SUBDIRS = .
if !MOO_OS_CYGWIN
SUBDIRS += tests
endif
DIST_SUBDIRS = m4
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = moo.pc
@ -25,7 +20,9 @@ AM_CFLAGS = \
$(CFLAGS)
if !MOO_OS_CYGWIN
noinst_LTLIBRARIES = libmoo-1.0.la
if MOO_BUILD_LIB
# noinst_LTLIBRARIES = libmoo-1.0.la
endif
endif
###########################################################################
@ -57,17 +54,24 @@ mooutils_include_HEADERS = $(mooutils_include_headers)
###########################################################################
CLEANFILES = $(moo_cleanfiles)
if !MOO_OS_CYGWIN
libmoo_1_0_la_LDFLAGS = -version-info $(LTVERSION) -export-symbols-regex "^[^_].*" -no-undefined
libmoo_1_0_la_SOURCES = $(moo_sources)
BUILT_SOURCES = $(moo_built_sources)
nodist_libmoo_1_0_la_SOURCES = $(moo_nodist_sources)
libmoo_ldflags = -version-info $(LTVERSION) -export-symbols-regex "^[^_].*" -no-undefined
libmoo_sources = $(moo_sources)
nodist_libmoo_sources = $(moo_nodist_sources)
if MOO_OS_MINGW
libmoo_1_0_la_SOURCES += $(moo_win32_sources)
libmoo_sources += $(moo_win32_sources)
endif
if MOO_OS_UNIX
libmoo_1_0_la_SOURCES += $(moo_unix_sources)
libmoo_sources += $(moo_unix_sources)
endif
if !MOO_OS_CYGWIN
if MOO_BUILD_LIB
# libmoo_1_0_la_LDFLAGS = $(libmoo_ldflags)
# libmoo_1_0_la_SOURCES = $(libmoo_sources)
# nodist_libmoo_1_0_la_SOURCES = $(nodist_libmoo_sources)
endif
endif
@ -84,21 +88,27 @@ $(moo_extra_dist)
#
if BUILD_PYMOO
pyexec_LTLIBRARIES = moo.la
moo_la_SOURCES = $(libmoo_1_0_la_SOURCES)
nodist_moo_la_SOURCES = $(nodist_libmoo_1_0_la_SOURCES)
if MOO_OS_MINGW
mingw_flags = -no-undefined
endif MOO_OS_MINGW
moo_la_LDFLAGS = -module -avoid-version -no-undefined -export-symbols-regex "initmoo"
moo_la_LIBADD = \
$(GTK_LIBS) \
$(XML_LIBS) \
$(PYTHON_LDFLAGS) \
$(PYTHON_EXTRA_LIBS)
# pyexec_LTLIBRARIES = moo.la
#
# moo_la_SOURCES = $(libmoo_sources)
# nodist_moo_la_SOURCES = $(nodist_libmoo_sources)
#
# if MOO_OS_MINGW
# mingw_flags = -no-undefined
# endif MOO_OS_MINGW
#
# moo_la_LDFLAGS = -module -avoid-version -no-undefined -export-symbols-regex "initmoo"
#
# moo_la_LIBADD = \
# $(GTK_LIBS) \
# $(XML_LIBS) \
# $(PYTHON_LDFLAGS) \
# $(PYTHON_EXTRA_LIBS)
endif BUILD_PYMOO
##############################################################################
# tests
#
include tests/Makefile.incl

View File

@ -35,8 +35,8 @@ AC_DEFINE(MOO_VERSION_MICRO, [moo_micro_version], "libmoo micro version")
AC_PROG_CC
AC_PROG_CC_STDC
AC_HEADER_STDC
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
# AC_LIBTOOL_WIN32_DLL
# AC_PROG_LIBTOOL
AC_PROG_INSTALL
MOO_AC_PROG_WINDRES
@ -214,6 +214,7 @@ AC_DEFINE_UNQUOTED(MOO_PLUGINS_DIR, "${mooprefix}/${moolibdir}/plugins", [plugin
AM_CONDITIONAL(MOO_STANDALONE, true)
AM_CONDITIONAL(MOO_BUILD_LIB, false)
################################################################################
@ -223,7 +224,6 @@ AC_OUTPUT([
Makefile
moo/moo-config.h
moo/mooterm/termhelper_res.rc
tests/Makefile
tests/pyapp.py
m4/Makefile
moo.pc

View File

@ -24,7 +24,7 @@
</ignoreparts>
<projectdirectory>.</projectdirectory>
<absoluteprojectpath>false</absoluteprojectpath>
<description></description>
<description/>
<secondaryLanguages>
<language>C</language>
</secondaryLanguages>
@ -36,10 +36,10 @@
<useconfiguration>debug</useconfiguration>
</general>
<run>
<mainprogram>tests/medit</mainprogram>
<mainprogram>./medit</mainprogram>
<directoryradio>executable</directoryradio>
<customdirectory>/</customdirectory>
<programargs></programargs>
<programargs/>
<terminal>false</terminal>
<autocompile>false</autocompile>
<envvars/>
@ -85,16 +85,16 @@
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevg77options</f77compiler>
<cflags></cflags>
<cxxflags></cxxflags>
<cflags/>
<cxxflags/>
<envvars/>
<topsourcedir></topsourcedir>
<cppflags></cppflags>
<ldflags></ldflags>
<ccompilerbinary></ccompilerbinary>
<cxxcompilerbinary></cxxcompilerbinary>
<f77compilerbinary></f77compilerbinary>
<f77flags></f77flags>
<topsourcedir/>
<cppflags/>
<ldflags/>
<ccompilerbinary/>
<cxxcompilerbinary/>
<f77compilerbinary/>
<f77flags/>
</optimized>
<gcc-4.0>
<configargs>--enable-all-gcc-warnings=fatal --enable-debug=full </configargs>
@ -192,7 +192,7 @@
<abortonerror>true</abortonerror>
<numberofjobs>3</numberofjobs>
<dontact>false</dontact>
<makebin></makebin>
<makebin/>
<prio>0</prio>
</make>
</kdevautoproject>
@ -200,10 +200,10 @@
<general>
<dbgshell>libtool</dbgshell>
<programargs>--g-fatal-warnings </programargs>
<gdbpath></gdbpath>
<configGdbScript></configGdbScript>
<runShellScript></runShellScript>
<runGdbScript></runGdbScript>
<gdbpath/>
<configGdbScript/>
<runShellScript/>
<runGdbScript/>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>true</floatingtoolbar>
@ -304,7 +304,7 @@
</codecompletion>
<references/>
<creategettersetter>
<prefixGet></prefixGet>
<prefixGet/>
<prefixSet>set</prefixSet>
<prefixVariable>m_,_</prefixVariable>
<parameterName>theValue</parameterName>

View File

@ -915,6 +915,7 @@ moo_edit_choose_indenter (MooEdit *edit)
indenter = moo_indenter_new (edit, name);
moo_text_view_set_indenter (MOO_TEXT_VIEW (edit), indenter);
g_object_unref (indenter);
}

View File

@ -19,9 +19,8 @@
#define IDLE_HIGHLIGHT_PRIORITY GTK_TEXT_VIEW_PRIORITY_VALIDATE
// #define IDLE_HIGHLIGHT_PRIORITY G_PRIORITY_DEFAULT_IDLE
#define IDLE_HIGHLIGHT_TIME 30
// #define IDLE_QUEUE_TIMEOUT 100
#define IDLE_HIGHLIGHT_TIME 30
#define COMPUTE_NOW_TIME 20
static MooSyntaxTag *iter_get_syntax_tag (const GtkTextIter *iter);
@ -50,14 +49,12 @@ static CtxNode *get_next_node (MooHighlighter *hl,
static CtxNode *get_line_end_node (MooHighlighter *hl,
CtxNode *node);
static void hl_compute_line (MooHighlighter *hl,
static CtxNode *hl_compute_line (MooHighlighter *hl,
Line *line,
int line_no,
MatchData *data,
CtxNode **node_p,
gboolean apply_tags,
gboolean is_empty);
static void hl_compute_range (MooHighlighter *hl,
CtxNode *node,
gboolean apply_tags);
static gboolean hl_compute_range (MooHighlighter *hl,
Interval *lines,
gboolean apply_tags,
int time);
@ -132,9 +129,10 @@ moo_highlighter_destroy (MooHighlighter *hl,
if (hl->lang)
moo_lang_unref (hl->lang);
if (hl->idle)
g_source_remove (hl->idle);
if (hl->apply_idle)
g_source_remove (hl->apply_idle);
g_free (hl);
}
@ -143,8 +141,7 @@ moo_highlighter_destroy (MooHighlighter *hl,
GtkTextTag *
_moo_text_iter_get_syntax_tag (const GtkTextIter *iter)
{
MooSyntaxTag *tag = iter_get_syntax_tag (iter);
return tag ? GTK_TEXT_TAG (tag) : NULL;
return (GtkTextTag*) iter_get_syntax_tag (iter);
}
@ -184,14 +181,13 @@ _moo_text_iter_get_context (const GtkTextIter *iter)
static void
apply_tag (MooHighlighter *hl,
Line *line,
CtxNode *ctx_node,
CtxNode *match_node,
MooRule *rule,
const GtkTextIter *start,
const GtkTextIter *end,
gboolean remove_old)
const GtkTextIter *end)
{
GtkTextIter tag_start = *start;
GtkTextTag *tag = get_syntax_tag (hl, ctx_node, match_node, rule);
g_assert (!tag || (MOO_IS_SYNTAX_TAG (tag) && MOO_SYNTAX_TAG(tag)->rule == rule));
@ -200,37 +196,13 @@ apply_tag (MooHighlighter *hl,
if (!gtk_text_iter_compare (start, end))
return;
while (remove_old && gtk_text_iter_compare (&tag_start, end) < 0)
{
MooSyntaxTag *old_tag = iter_get_syntax_tag (&tag_start);
if (old_tag && (old_tag != (MooSyntaxTag*) tag))
{
GtkTextIter tag_end = tag_start;
g_assert (!gtk_text_iter_ends_tag (&tag_end, GTK_TEXT_TAG (old_tag)));
gtk_text_iter_forward_to_tag_toggle (&tag_end, GTK_TEXT_TAG (old_tag));
if (gtk_text_iter_compare (end, &tag_end) < 0)
tag_end = *end;
gtk_text_buffer_remove_tag (hl->buffer, GTK_TEXT_TAG (old_tag), &tag_start, &tag_end);
tag_start = tag_end;
}
else
{
if (!gtk_text_iter_forward_to_tag_toggle (&tag_start, NULL))
break;
}
}
g_assert (iter_get_syntax_tag (start) == NULL ||
iter_get_syntax_tag (start) == MOO_SYNTAX_TAG (tag));
g_assert (iter_get_syntax_tag (start) == NULL);
if (tag)
{
line->hl_info->tags = g_slist_prepend (line->hl_info->tags, tag);
_moo_text_buffer_apply_syntax_tag (MOO_TEXT_BUFFER (hl->buffer), tag, start, end);
}
}
@ -451,85 +423,100 @@ get_next_line_node (MooHighlighter *hl,
}
static void
static CtxNode *
hl_compute_line (MooHighlighter *hl,
Line *line,
int line_no,
MatchData *data,
CtxNode **node_p,
gboolean apply_tags,
gboolean dirty)
CtxNode *node,
gboolean apply_tags)
{
CtxNode *node = *node_p;
MooRule *matched_rule = NULL;
MooRule *matched_rule;
MatchResult result;
if (apply_tags && line->hl_info->tags && !gtk_text_iter_ends_line (&data->start_iter))
{
GtkTextIter start = data->start_iter;
GtkTextIter end = data->start_iter;
GSList *tags = line->hl_info->tags;
line->hl_info->tags = NULL;
gtk_text_iter_forward_to_line_end (&end);
while (tags)
{
gtk_text_buffer_remove_tag (hl->buffer, tags->data, &start, &end);
tags = g_slist_delete_link (tags, tags);
}
}
while (!gtk_text_iter_ends_line (&data->start_iter))
{
if ((matched_rule = moo_rule_array_match (node->ctx->rules, data, &result)))
{
CtxNode *match_node, *next_node;
if (result.match_offset < 0)
result.match_offset = g_utf8_pointer_to_offset (data->start, result.match_start);
if (result.match_len < 0)
result.match_len = g_utf8_pointer_to_offset (result.match_start, result.match_end);
moo_line_add_segment (line, result.match_offset, node, NULL, NULL);
next_node = get_next_node (hl, node, matched_rule);
if (matched_rule->flags & MOO_RULE_INCLUDE_INTO_NEXT)
match_node = next_node;
else
match_node = node;
moo_line_add_segment (line, result.match_len, match_node, node, matched_rule);
if (apply_tags)
{
GtkTextIter m_start = data->start_iter, m_end;
gtk_text_iter_forward_chars (&m_start, result.match_offset);
m_end = m_start;
gtk_text_iter_forward_chars (&m_end, result.match_len);
apply_tag (hl, line, node, NULL, NULL, &data->start_iter, &m_start);
apply_tag (hl, line, match_node, node, matched_rule, &m_start, &m_end);
moo_match_data_set_start (data, &m_end, result.match_end,
data->start_offset + result.match_offset + result.match_len);
}
else
{
moo_match_data_set_start (data, NULL, result.match_end,
data->start_offset + result.match_offset + result.match_len);
}
node = next_node;
}
else
{
moo_line_add_segment (line, -1, node, NULL, NULL);
if (apply_tags)
{
GtkTextIter eol = data->start_iter;
gtk_text_iter_forward_to_line_end (&eol);
apply_tag (hl, line, node, NULL, NULL, &data->start_iter, &eol);
}
break;
}
}
if (apply_tags)
LINE_SET_TAGS_APPLIED (line);
line->hl_info->tags_applied = TRUE;
if (!gtk_text_iter_ends_line (&data->start_iter) &&
(matched_rule = moo_rule_array_match (node->ctx->rules, data, &result)))
{
CtxNode *match_node;
/* XXX make it a cycle instead of recursive function */
if (result.match_offset < 0)
result.match_offset = g_utf8_pointer_to_offset (data->start, result.match_start);
if (result.match_len < 0)
result.match_len = g_utf8_pointer_to_offset (result.match_start, result.match_end);
moo_line_add_segment (line, result.match_offset, node, NULL, NULL);
*node_p = get_next_node (hl, node, matched_rule);
if (matched_rule->flags & MOO_RULE_INCLUDE_INTO_NEXT)
match_node = *node_p;
else
match_node = node;
moo_line_add_segment (line, result.match_len, match_node, node, matched_rule);
if (apply_tags)
{
GtkTextIter m_start = data->start_iter, m_end;
gtk_text_iter_forward_chars (&m_start, result.match_offset);
m_end = m_start;
gtk_text_iter_forward_chars (&m_end, result.match_len);
apply_tag (hl, node, NULL, NULL, &data->start_iter, &m_start, dirty);
apply_tag (hl, match_node, node, matched_rule, &m_start, &m_end, dirty);
moo_match_data_set_start (data, &m_end, result.match_end,
data->start_offset + result.match_offset + result.match_len);
}
else
{
moo_match_data_set_start (data, NULL, result.match_end,
data->start_offset + result.match_offset + result.match_len);
}
return hl_compute_line (hl, line, line_no, data, node_p, apply_tags, dirty);
}
if (!gtk_text_iter_ends_line (&data->start_iter))
{
moo_line_add_segment (line, -1, node, NULL, NULL);
if (apply_tags)
{
GtkTextIter eol = data->start_iter;
gtk_text_iter_forward_to_line_end (&eol);
apply_tag (hl, node, NULL, NULL, &data->start_iter, &eol, dirty);
}
}
*node_p = get_next_line_node (hl, line);
return get_next_line_node (hl, line);
}
static void
static gboolean
hl_compute_range (MooHighlighter *hl,
Interval *lines,
gboolean apply_tags,
@ -537,7 +524,7 @@ hl_compute_range (MooHighlighter *hl,
{
GtkTextIter iter;
CtxNode *node;
int line_no, last_changed;
int line_no;
GTimer *timer = NULL;
double secs = ((double) time) / 1000;
gboolean done = FALSE;
@ -562,28 +549,26 @@ hl_compute_range (MooHighlighter *hl,
node = get_next_line_node (hl, prev);
}
g_return_if_fail (node != NULL);
g_return_val_if_fail (node != NULL, TRUE);
gtk_text_buffer_get_iter_at_line (hl->buffer, &iter, lines->first);
for (line_no = lines->first; line_no <= lines->last; ++line_no)
{
Line *line = moo_line_buffer_get_line (hl->line_buf, line_no);
gboolean dirty = LINE_DIRTY (line);
MatchData match_data;
g_assert (dirty || !LINE_TAGS_APPLIED (line));
g_assert (line->hl_info->tags || !line->hl_info->tags_applied);
g_assert (line_no == gtk_text_iter_get_line (&iter));
last_changed = line_no;
line->hl_info->start_node = node;
LINE_UNSET_TAGS_APPLIED (line);
line->hl_info->tags_applied = FALSE;
moo_line_erase_segments (line);
/* TODO: there is no need to recompute line if its start context matches
context implied by the previous line */
moo_match_data_init (&match_data, line_no, &iter, NULL);
hl_compute_line (hl, line, line_no, &match_data, &node, apply_tags, dirty);
node = hl_compute_line (hl, line, &match_data, node, apply_tags);
moo_match_data_destroy (&match_data);
if (!gtk_text_iter_forward_line (&iter))
@ -632,12 +617,12 @@ out:
g_timer_destroy (timer);
_moo_text_buffer_highlighting_changed (MOO_TEXT_BUFFER (hl->buffer),
lines->first, last_changed);
return;
lines->first, line_no);
return done;
}
static void
static gboolean
moo_highlighter_compute_timed (MooHighlighter *hl,
int first_line,
int last_line,
@ -647,10 +632,10 @@ moo_highlighter_compute_timed (MooHighlighter *hl,
Interval to_highlight;
if (!hl->lang || !hl->buffer)
return;
return TRUE;
if (BUF_CLEAN (hl->line_buf))
return;
return TRUE;
if (last_line < 0)
last_line = moo_text_btree_size (hl->line_buf->tree) - 1;
@ -662,10 +647,10 @@ moo_highlighter_compute_timed (MooHighlighter *hl,
to_highlight.last = last_line;
if (hl->line_buf->invalid.first > to_highlight.last)
return;
return TRUE;
to_highlight.first = hl->line_buf->invalid.first;
hl_compute_range (hl, &to_highlight, apply_tags, time);
return hl_compute_range (hl, &to_highlight, apply_tags, time);
}
@ -689,7 +674,10 @@ compute_in_idle (MooHighlighter *hl)
IDLE_HIGHLIGHT_TIME);
if (!BUF_CLEAN (hl->line_buf))
moo_highlighter_queue_compute (hl, hl->apply_tags);
hl->idle = g_timeout_add_full (IDLE_HIGHLIGHT_PRIORITY,
IDLE_HIGHLIGHT_TIME,
(GSourceFunc) compute_in_idle,
hl, NULL);
return FALSE;
}
@ -711,22 +699,53 @@ moo_highlighter_queue_compute (MooHighlighter *hl,
}
static gboolean
apply_in_idle (MooHighlighter *hl)
{
hl->apply_idle = 0;
hl->apply_to.empty = TRUE;
moo_highlighter_apply_tags (hl, hl->apply_to.first, hl->apply_to.last);
return FALSE;
}
void
moo_highlighter_apply_tags (MooHighlighter *hl,
int first_line,
int last_line)
{
int line_no;
int total;
int first_changed, last_changed;
if (!hl->lang || !hl->buffer)
return;
total = moo_text_btree_size (hl->line_buf->tree);
if (last_line < 0)
last_line = moo_text_btree_size (hl->line_buf->tree) - 1;
last_line = total - 1;
first_line = CLAMP (first_line, 0, total - 1);
last_line = CLAMP (last_line, first_line, total - 1);
g_assert (first_line >= 0);
g_assert (last_line >= first_line);
if (!moo_highlighter_compute_timed (hl, first_line, last_line,
TRUE, COMPUTE_NOW_TIME))
{
if (!hl->apply_idle)
hl->apply_idle = g_idle_add ((GSourceFunc) apply_in_idle, hl);
hl->apply_to.empty = FALSE;
hl->apply_to.first = first_line;
hl->apply_to.last = last_line;
return;
}
first_changed = -1;
moo_highlighter_compute (hl, first_line, last_line, TRUE);
for (line_no = first_line; line_no <= last_line; ++line_no)
@ -735,40 +754,54 @@ moo_highlighter_apply_tags (MooHighlighter *hl,
HLInfo *info = line->hl_info;
guint i;
GtkTextIter t_start, t_end;
gboolean got_iter = FALSE;
GSList *tags;
if (LINE_TAGS_APPLIED (line))
if (line->hl_info->tags_applied)
continue;
if (first_changed < 0)
first_changed = line_no;
last_changed = line_no;
line->hl_info->tags_applied = TRUE;
gtk_text_buffer_get_iter_at_line (hl->buffer, &t_start, line_no);
if (gtk_text_iter_ends_line (&t_start))
continue;
t_end = t_start;
gtk_text_iter_forward_to_line_end (&t_end);
tags = line->hl_info->tags;
line->hl_info->tags = NULL;
while (tags)
{
gtk_text_buffer_remove_tag (hl->buffer, tags->data, &t_start, &t_end);
tags = g_slist_delete_link (tags, tags);
}
t_end = t_start;
for (i = 0; i < info->n_segments; ++i)
{
if (!info->segments[i].len)
continue;
if (!got_iter)
{
gtk_text_buffer_get_iter_at_line (hl->buffer, &t_start, line_no);
t_end = t_start;
got_iter = TRUE;
}
else
{
t_start = t_end;
}
if (info->segments[i].len < 0)
gtk_text_iter_forward_to_line_end (&t_end);
else
gtk_text_iter_forward_chars (&t_end, info->segments[i].len);
apply_tag (hl, info->segments[i].ctx_node,
apply_tag (hl, line, info->segments[i].ctx_node,
info->segments[i].match_node,
info->segments[i].rule,
&t_start, &t_end, LINE_DIRTY (line));
}
&t_start, &t_end);
LINE_SET_TAGS_APPLIED (line);
t_start = t_end;
}
}
if (first_changed >= 0)
_moo_text_buffer_highlighting_changed (MOO_TEXT_BUFFER (hl->buffer),
first_changed, last_changed);
}

View File

@ -54,6 +54,8 @@ struct _MooHighlighter {
GSList *nodes;
guint idle;
gboolean apply_tags;
guint apply_idle;
Area apply_to;
};
struct _MooSyntaxTag {

View File

@ -63,13 +63,23 @@ moo_line_buffer_delete (LineBuffer *line_buf,
void
moo_line_buffer_insert_range (LineBuffer *line_buf,
int first,
int num)
moo_line_buffer_split_line (LineBuffer *line_buf,
int line,
int num_new_lines)
{
moo_text_btree_insert_range (line_buf->tree, first, num);
/* XXX is it needed? */
moo_line_buffer_invalidate (line_buf, first);
Line *l;
GSList *tags;
moo_text_btree_insert_range (line_buf->tree, line + 1, num_new_lines);
l = moo_line_buffer_get_line (line_buf, line);
invalidate_line (line_buf, l, line);
tags = g_slist_copy (l->hl_info->tags);
l = moo_line_buffer_get_line (line_buf, line + num_new_lines);
invalidate_line (line_buf, l, line + num_new_lines);
g_assert (l->hl_info->tags == NULL);
l->hl_info->tags = tags;
}
@ -90,8 +100,7 @@ invalidate_line_one (Line *line)
{
moo_line_erase_segments (line);
line->hl_info->start_node = NULL;
line->hl_info->_dirty = TRUE;
line->hl_info->_tags_applied = FALSE;
line->hl_info->tags_applied = FALSE;
}
void
@ -127,7 +136,7 @@ invalidate_line (LineBuffer *line_buf,
void
moo_line_buffer_invalidate_all (LineBuffer *line_buf)
{
moo_text_btree_foreach (line_buf->tree, (MooTextBTreeForeach) invalidate_line_one, NULL);
moo_line_buffer_invalidate (line_buf, 0);
AREA_SET (&line_buf->invalid, moo_text_btree_size (line_buf->tree));
}

View File

@ -59,9 +59,8 @@ struct _HLInfo {
Segment *segments;
guint n_segments;
guint n_segments_alloc__;
/* tags_applied => dirty */
guint _dirty : 1; /* need to remove tags before applying next */
guint _tags_applied : 1; /* correct highlighting tags were applied */
GSList *tags; /* tags applied in this line */
guint tags_applied : 1; /* correct highlighting tags were applied */
};
@ -80,9 +79,9 @@ void moo_line_buffer_invalidate (LineBuffer *line_buf,
void moo_line_buffer_invalidate_all (LineBuffer *line_buf);
void moo_line_buffer_clamp_invalid (LineBuffer *line_buf);
void moo_line_buffer_insert_range (LineBuffer *line_buf,
int first,
int last);
void moo_line_buffer_split_line (LineBuffer *line_buf,
int line,
int num_new_lines);
void moo_line_buffer_delete_range (LineBuffer *line_buf,
int first,
int last);

View File

@ -218,6 +218,7 @@ hl_info_free (HLInfo *info)
{
#ifdef __MOO__
g_free (info->segments);
g_slist_free (info->tags);
hl_info_free__ (info);
#endif
}
@ -516,28 +517,6 @@ moo_text_btree_delete (BTree *tree,
}
void
moo_text_btree_get_iter_first (BTree *tree,
BTIter *iter)
{
guint i;
BTNode *node;
g_assert (tree != NULL && iter != NULL);
iter->tree = tree;
iter->stamp = tree->stamp;
for (i = 0, node = tree->root; i < tree->depth; ++i, node = node->children[0])
iter->indices[i] = 0;
iter->indices[tree->depth] = 0;
iter->depth = tree->depth + 1;
iter->is_data = TRUE;
iter->data = node->data[0];
}
/* XXX */
void
moo_text_btree_insert_range (BTree *tree,
@ -572,26 +551,6 @@ moo_text_btree_delete_range (BTree *tree,
}
/* XXX */
void
moo_text_btree_foreach (BTree *tree,
MooTextBTreeForeach func,
gpointer user_data)
{
guint i, size;
g_return_if_fail (tree != NULL && func != NULL);
size = moo_text_btree_size (tree);
for (i = 0; i < size; ++i)
{
BTData *data = moo_text_btree_get_data (tree, i);
func (data, user_data);
}
}
#ifdef WANT_CHECK_INTEGRITY
static void

View File

@ -37,7 +37,6 @@ typedef struct _BTree BTree;
typedef struct _HLInfo HLInfo;
typedef void (*MooTextBTreeForeach) (BTData *data, gpointer user_data);
struct _BTNode {
BTNode *parent;
@ -54,7 +53,6 @@ struct _BTNode {
struct _BTData {
BTNode *parent;
HLInfo *hl_info;
};
@ -64,20 +62,6 @@ struct _BTree {
guint stamp;
};
struct _BTIter {
BTree *tree;
union {
BTNode *node;
BTData *data;
};
guint8 indices[BTREE_MAX_DEPTH];
guint depth : BTREE_MAX_DEPTH_EXP;
guint is_data : 1;
guint stamp : (31 - BTREE_MAX_DEPTH_EXP);
};
BTree *moo_text_btree_new (void);
void moo_text_btree_free (BTree *tree);
@ -99,17 +83,6 @@ void moo_text_btree_delete_range (BTree *tree,
int first,
int num);
void moo_text_btree_foreach (BTree *tree,
MooTextBTreeForeach func,
gpointer data);
void moo_text_btree_get_iter_first (BTree *tree,
BTIter *iter);
gboolean moo_text_btree_iter_next (BTIter *iter);
gboolean moo_text_btree_iter_prev (BTIter *iter);
gboolean moo_text_btree_iter_parent (BTIter *iter);
gboolean moo_text_btree_iter_is_data (BTIter *iter);
G_END_DECLS

View File

@ -403,13 +403,15 @@ moo_text_buffer_insert_text (GtkTextBuffer *text_buffer,
moo_undo_mgr_add_action (buffer->priv->undo_mgr, INSERT_ACTION_TYPE, action);
}
if ((tag = _moo_text_iter_get_syntax_tag (pos)) &&
!gtk_text_iter_begins_tag (pos, tag))
if (((tag = buffer->priv->correct_match_tag) && gtk_text_iter_has_tag (pos, tag)) ||
((tag = buffer->priv->incorrect_match_tag) && gtk_text_iter_has_tag (pos, tag)))
{
/* new text is gonna get this tag applied, so we better remove it */
GtkTextIter next = *pos;
gtk_text_iter_forward_char (&next);
gtk_text_buffer_remove_tag (text_buffer, tag, pos, &next);
if (!gtk_text_iter_begins_tag (pos, tag))
{
GtkTextIter next = *pos;
gtk_text_iter_forward_char (&next);
gtk_text_buffer_remove_tag (text_buffer, tag, pos, &next);
}
}
GTK_TEXT_BUFFER_CLASS(moo_text_buffer_parent_class)->insert_text (text_buffer, pos, text, length);
@ -417,17 +419,10 @@ moo_text_buffer_insert_text (GtkTextBuffer *text_buffer,
last_line = gtk_text_iter_get_line (pos);
if (last_line == first_line)
{
moo_line_buffer_invalidate (buffer->priv->line_buf, first_line);
}
else
{
moo_line_buffer_insert_range (buffer->priv->line_buf,
first_line + 1,
last_line - first_line);
moo_line_buffer_invalidate (buffer->priv->line_buf, first_line);
moo_line_buffer_invalidate (buffer->priv->line_buf, last_line);
}
moo_line_buffer_split_line (buffer->priv->line_buf,
first_line, last_line - first_line);
moo_text_buffer_queue_highlight (buffer);

View File

@ -94,6 +94,9 @@ struct _MooTextViewPrivate {
/***********************************************************************/
/* Drawing
/*/
gboolean in_expose;
GdkRegion *update_region;
guint update_idle;
gboolean highlight_current_line;
GdkColor current_line_color;
GdkGC *current_line_gc;

View File

@ -26,6 +26,7 @@
#define LIGHT_BLUE "#EEF6FF"
#define BOOL_CMP(b1,b2) ((b1 && b2) || (!b1 && !b2))
#define UPDATE_PRIORITY (GTK_TEXT_VIEW_PRIORITY_VALIDATE - 5)
static GObject *moo_text_view_constructor (GType type,
guint n_construct_properties,
@ -965,12 +966,6 @@ moo_text_view_set_indenter (MooTextView *view,
if (view->priv->indenter)
g_object_ref (view->priv->indenter);
// if (view->priv->indenter)
// gtk_source_view_set_tabs_width (GTK_SOURCE_VIEW (view),
// view->priv->indenter->tab_width);
// else
// gtk_source_view_set_tabs_width (GTK_SOURCE_VIEW (view), 8);
g_object_notify (G_OBJECT (view), "indenter");
}
@ -1274,6 +1269,13 @@ moo_text_view_unrealize (GtkWidget *widget)
add_selection_clipboard (view);
}
if (view->priv->update_idle)
{
g_source_remove (view->priv->update_idle);
gdk_region_destroy (view->priv->update_region);
view->priv->update_region = NULL;
}
GTK_WIDGET_CLASS(moo_text_view_parent_class)->unrealize (widget);
}
@ -1441,6 +1443,8 @@ moo_text_view_expose (GtkWidget *widget,
GtkTextIter start, end;
int first_line, last_line;
view->priv->in_expose = TRUE;
if (view->priv->highlight_current_line &&
event->window == text_window && view->priv->current_line_gc)
moo_text_view_draw_current_line (text_view, event);
@ -1477,39 +1481,73 @@ moo_text_view_expose (GtkWidget *widget,
if (event->window == text_window && view->priv->draw_trailing_spaces)
moo_text_view_draw_trailing_spaces (text_view, event, &start, &end);
view->priv->in_expose = FALSE;
return handled;
}
static gboolean
update_idle (MooTextView *view)
{
GdkRegion *region = view->priv->update_region;
GdkWindow *window = gtk_text_view_get_window (GTK_TEXT_VIEW (view),
GTK_TEXT_WINDOW_TEXT);
view->priv->update_idle = 0;
view->priv->update_region = NULL;
gdk_window_invalidate_region (window, region, FALSE);
gdk_region_destroy (region);
return FALSE;
}
static void
highlighting_changed (GtkTextView *view,
highlighting_changed (GtkTextView *text_view,
const GtkTextIter *start,
const GtkTextIter *end)
{
GdkRectangle visible, redraw;
GdkRectangle visible, changed, update;
int y, height;
MooTextView *view = MOO_TEXT_VIEW (text_view);
if (!GTK_WIDGET_DRAWABLE (view))
if (!GTK_WIDGET_DRAWABLE (text_view))
return;
gtk_text_view_get_visible_rect (view, &visible);
gtk_text_view_get_visible_rect (text_view, &visible);
gtk_text_view_get_line_yrange (view, start, &redraw.y, &redraw.height);
gtk_text_view_get_line_yrange (view, end, &y, &height);
redraw.height += y + redraw.y;
redraw.x = visible.x;
redraw.width = visible.width;
gtk_text_view_get_line_yrange (text_view, start, &changed.y, &height);
gtk_text_view_get_line_yrange (text_view, end, &y, &height);
changed.height = y - changed.y + height;
changed.x = visible.x;
changed.width = visible.width;
if (gdk_rectangle_intersect (&redraw, &visible, &redraw))
if (gdk_rectangle_intersect (&changed, &visible, &update))
{
GdkWindow *window = gtk_text_view_get_window (view, GTK_TEXT_WINDOW_TEXT);
gtk_text_view_buffer_to_window_coords (view,
GdkWindow *window = gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT);
gtk_text_view_buffer_to_window_coords (text_view,
GTK_TEXT_WINDOW_TEXT,
redraw.x,
redraw.y,
&redraw.x,
&redraw.y);
gdk_window_invalidate_rect (window, &redraw, FALSE);
update.x,
update.y,
&update.x,
&update.y);
if (view->priv->in_expose)
{
if (view->priv->update_region)
gdk_region_union_with_rect (view->priv->update_region,
&update);
else
view->priv->update_region = gdk_region_rectangle (&update);
if (!view->priv->update_idle)
view->priv->update_idle = g_idle_add_full (UPDATE_PRIORITY,
(GSourceFunc) update_idle,
view, NULL);
}
else
{
gdk_window_invalidate_rect (window, &update, TRUE);
}
}
}

View File

@ -1,126 +0,0 @@
#
# tests/Makefile.am
#
EXTRA_PROGRAMS = medit mterm markup termbuffer testfileview testpaned testpanedfileview miniglade langparser testobject
bin_PROGRAMS =
noinst_PROGRAMS =
EXTRA_DIST = \
pyapp.py.in \
medit-ui.xml
BUILT_SOURCES = medit-ui.h
medit-ui.h: medit-ui.xml
sh $(srcdir)/../moo/mooutils/xml2h.sh MEDIT_UI $(srcdir)/medit-ui.xml > medit-ui.h
all-am: pyapp.py medit-ui.h
if MOO_BUILD_APP
medit = medit
endif
if MOO_BUILD_EDIT
medit = medit
endif
if MOO_BUILD_TERM
# noinst_PROGRAMS += mterm termbuffer
endif
if MOO_BUILD_UTILS
# noinst_PROGRAMS += testpanedfileview
# noinst_PROGRAMS += testobject
# noinst_PROGRAMS += markup miniglade
endif
bin_PROGRAMS += $(medit)
AM_CFLAGS = \
-I$(top_builddir) \
$(MOO_CFLAGS) \
$(MOO_DEBUG_CFLAGS) \
$(CFLAGS) \
$(GTK_CFLAGS)
ldflags = -export-dynamic
ldadd = \
../libmoo-1.0.la \
$(MOO_LIBS) \
$(PYTHON_LDFLAGS) \
$(PYTHON_EXTRA_LIBS)
if MOO_OS_MINGW
ldflags += -mwindows
endif MOO_OS_MINGW
##############################################################################
## medit
##
medit_LDFLAGS = $(ldflags)
medit_LDADD = $(ldadd)
medit_SOURCES = medit-ui.h
if MOO_BUILD_APP
medit_SOURCES += medit-app.c
else
medit_SOURCES += medit.c
endif
##############################################################################
## langparser
##
langparser_LDFLAGS = $(ldflags)
langparser_LDADD = $(ldadd)
langparser_SOURCES = testparser.c
##############################################################################
## mterm
##
mterm_LDFLAGS = $(ldflags)
mterm_LDADD = $(ldadd)
termbuffer_LDFLAGS = $(ldflags)
termbuffer_LDADD = $(ldadd)
mterm_SOURCES = mterm.c
termbuffer_SOURCES = termbuffer.c
##############################################################################
## markup
##
markup_LDFLAGS = $(ldflags)
markup_LDADD = $(ldadd)
markup_SOURCES = markup.c
##############################################################################
## miniglade
##
miniglade_LDFLAGS = $(ldflags)
miniglade_LDADD = $(ldadd)
miniglade_SOURCES = miniglade.c
##############################################################################
testpaned_LDFLAGS = $(ldflags)
testpaned_LDADD = $(ldadd)
testpaned_SOURCES = testpaned.c
testfileview_LDFLAGS = $(ldflags)
testfileview_LDADD = $(ldadd)
testfileview_SOURCES = testfileview.c
testpanedfileview_LDFLAGS = $(ldflags)
testpanedfileview_LDADD = $(ldadd)
testpanedfileview_SOURCES = testpanedfileview.c
testobject_LDFLAGS = $(ldflags)
testobject_LDADD = $(ldadd)
testobject_SOURCES = testobject.c

151
tests/Makefile.incl Normal file
View File

@ -0,0 +1,151 @@
EXTRA_PROGRAMS += medit mterm markup termbuffer testfileview testpaned testpanedfileview miniglade langparser testobject
bin_PROGRAMS =
noinst_PROGRAMS =
EXTRA_DIST += \
tests/pyapp.py.in \
tests/medit-ui.xml
BUILT_SOURCES += medit-ui.h
medit-ui.h: tests/medit-ui.xml
sh $(srcdir)/moo/mooutils/xml2h.sh MEDIT_UI $(srcdir)/tests/medit-ui.xml > medit-ui.h
all-am: tests/pyapp.py tests/medit-ui.h
if MOO_BUILD_APP
medit = medit
endif
if MOO_BUILD_EDIT
medit = medit
endif
if MOO_BUILD_TERM
# noinst_PROGRAMS += mterm termbuffer
endif
if MOO_BUILD_UTILS
# noinst_PROGRAMS += testpanedfileview
# noinst_PROGRAMS += testobject
# noinst_PROGRAMS += markup miniglade
endif
bin_PROGRAMS += $(medit)
ldflags = -export-dynamic
ldadd = \
$(MOO_LIBS) \
$(PYTHON_LDFLAGS) \
$(PYTHON_EXTRA_LIBS)
if MOO_BUILD_LIB
ldadd += libmoo-1.0.la
endif
if MOO_OS_MINGW
ldflags += -mwindows
endif MOO_OS_MINGW
##############################################################################
## medit
##
medit_LDFLAGS = $(ldflags)
medit_LDADD = $(ldadd)
medit_SOURCES = tests/medit-ui.h
if !MOO_BUILD_LIB
medit_SOURCES += $(libmoo_sources)
nodist_medit_SOURCES = $(nodist_libmoo_sources)
endif
if MOO_BUILD_APP
medit_SOURCES += tests/medit-app.c
else
medit_SOURCES += tests/medit.c
endif
##############################################################################
## langparser
##
langparser_LDFLAGS = $(ldflags)
langparser_LDADD = $(ldadd)
langparser_SOURCES = tests/testparser.c
if !MOO_BUILD_LIB
langparser_SOURCES += $(libmoo_sources)
nodist_langparser_SOURCES = $(nodist_libmoo_sources)
endif
##############################################################################
## mterm
##
mterm_LDFLAGS = $(ldflags)
mterm_LDADD = $(ldadd)
termbuffer_LDFLAGS = $(ldflags)
termbuffer_LDADD = $(ldadd)
mterm_SOURCES = tests/mterm.c
termbuffer_SOURCES = tests/termbuffer.c
if !MOO_BUILD_LIB
mterm_SOURCES += $(libmoo_sources)
nodist_mterm_SOURCES = $(nodist_libmoo_sources)
termbuffer_SOURCES += $(libmoo_sources)
nodist_termbuffer_SOURCES = $(nodist_libmoo_sources)
endif
##############################################################################
## markup
##
markup_LDFLAGS = $(ldflags)
markup_LDADD = $(ldadd)
markup_SOURCES = tests/markup.c
if !MOO_BUILD_LIB
markup_SOURCES += $(libmoo_sources)
nodist_markup_SOURCES = $(nodist_libmoo_sources)
endif
##############################################################################
## miniglade
##
miniglade_LDFLAGS = $(ldflags)
miniglade_LDADD = $(ldadd)
miniglade_SOURCES = tests/miniglade.c
if !MOO_BUILD_LIB
miniglade_SOURCES += $(libmoo_sources)
nodist_miniglade_SOURCES = $(nodist_libmoo_sources)
endif
##############################################################################
testpaned_LDFLAGS = $(ldflags)
testpaned_LDADD = $(ldadd)
testpaned_SOURCES = tests/testpaned.c
testfileview_LDFLAGS = $(ldflags)
testfileview_LDADD = $(ldadd)
testfileview_SOURCES = tests/testfileview.c
testpanedfileview_LDFLAGS = $(ldflags)
testpanedfileview_LDADD = $(ldadd)
testpanedfileview_SOURCES = tests/testpanedfileview.c
testobject_LDFLAGS = $(ldflags)
testobject_LDADD = $(ldadd)
testobject_SOURCES = tests/testobject.c
if !MOO_BUILD_LIB
testpaned_SOURCES += $(libmoo_sources)
testfileview_SOURCES += $(libmoo_sources)
testpanedfileview_SOURCES += $(libmoo_sources)
testobject_SOURCES += $(libmoo_sources)
nodist_testpaned_SOURCES = $(nodist_libmoo_sources)
nodist_testfileview_SOURCES = $(nodist_libmoo_sources)
nodist_testpanedfileview_SOURCES = $(nodist_libmoo_sources)
nodist_testobject_SOURCES = $(nodist_libmoo_sources)
endif