Removed URL highlighting code(useless feature, never was enabled).

Set policy settings for the scolledwindow.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@476 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2006-06-24 18:43:56 +00:00
parent 570793a6ef
commit 01ace30125
4 changed files with 42 additions and 111 deletions

View File

@ -10,7 +10,13 @@
tagmanager/tm_tag.c, tagmanager/tm_project, tagmanager/parsers.h, tagmanager/tm_tag.c, tagmanager/tm_project, tagmanager/parsers.h,
tagmanager/tm_file_entry.c, tagmanager/entry.c, src/highlighting.c, tagmanager/tm_file_entry.c, tagmanager/entry.c, src/highlighting.c,
data/latex.tags, data/php.tags, Makefile.am: data/latex.tags, data/php.tags, Makefile.am:
Added global auto completion tags for PHP and LaTeX. Added global auto completion tags for PHP and LaTeX.
* src/keybindings.c, src/callbacks.c, src/sci_cb.c, src/main.c,
src/geany.h, src/dialogs.c:
Added some sanity checks to prevent crashes.
* src/sci_cb.c, src/highlighting.c:
Removed URL highlighting code(useless feature, never was enabled).
* src/treeviews.c: Set policy settings for the scolledwindow.
2006-06-23 Nick Treleaven <nick.treleaven@btinternet.com> 2006-06-23 Nick Treleaven <nick.treleaven@btinternet.com>

View File

@ -801,9 +801,6 @@ void styleset_php(ScintillaObject *sci)
SSM (sci, SCI_SETPROPERTY, (sptr_t) "phpscript.mode", (sptr_t) "1"); SSM (sci, SCI_SETPROPERTY, (sptr_t) "phpscript.mode", (sptr_t) "1");
SSM (sci, SCI_SETLEXER, SCLEX_HTML, 0); SSM (sci, SCI_SETLEXER, SCLEX_HTML, 0);
// DWELL notification for URL highlighting
//SSM(sci, SCI_SETMOUSEDWELLTIME, 500, 0);
// use the same colouring for HTML; XML and so on // use the same colouring for HTML; XML and so on
styleset_markup(sci); styleset_markup(sci);

View File

@ -31,7 +31,6 @@
#include "sciwrappers.h" #include "sciwrappers.h"
#include "utils.h" #include "utils.h"
static gint link_start, link_end, style;
static gchar indent[100]; static gchar indent[100];
@ -212,19 +211,6 @@ void on_editor_notification(GtkWidget *editor, gint scn, gpointer lscn, gpointer
} }
break; break;
} }
case SCN_DWELLSTART:
{
//sci_cb_handle_uri(sci, nt->position);
break;
}
case SCN_DWELLEND:
{
/* gint end_of_styling = SSM(sci, SCI_GETENDSTYLED, 0, 0);
SSM(sci, SCI_STARTSTYLING, link_start, 31);
SSM(sci, SCI_SETSTYLING, (link_end - link_start) + 1, style);
SSM(sci, SCI_STARTSTYLING, end_of_styling, 31);
*/ break;
}
/* case SCN_STYLENEEDED: /* case SCN_STYLENEEDED:
{ {
geany_debug("style"); geany_debug("style");
@ -363,12 +349,17 @@ void sci_cb_close_block(ScintillaObject *sci, gint pos)
gboolean sci_cb_show_calltip(ScintillaObject *sci, gint pos) gboolean sci_cb_show_calltip(ScintillaObject *sci, gint pos)
{ {
gint lexer = SSM(sci, SCI_GETLEXER, 0, 0); gint lexer;
gint style; gint style;
gchar word[GEANY_MAX_WORD_LENGTH]; gchar word[GEANY_MAX_WORD_LENGTH];
gint idx = document_find_by_sci(sci); gint idx;
const GPtrArray *tags; const GPtrArray *tags;
if (sci == NULL) return FALSE;
lexer = SSM(sci, SCI_GETLEXER, 0, 0);
idx = document_find_by_sci(sci);
word[0] = '\0'; word[0] = '\0';
if (pos == -1) if (pos == -1)
{ // position of '(' is unknown, so go backwards to find it { // position of '(' is unknown, so go backwards to find it
@ -409,6 +400,16 @@ gboolean sci_cb_start_auto_complete(ScintillaObject *sci, gint pos)
gchar *root; gchar *root;
const GPtrArray *tags; const GPtrArray *tags;
if (sci == NULL) return FALSE;
line = sci_get_line_from_position(sci, pos);
line_start = sci_get_position_from_line(sci, line);
line_len = sci_get_line_length(sci, line);
line_pos = pos - line_start - 1;
current = pos - line_start;
startword = current, lexer = SSM(sci, SCI_GETLEXER, 0, 0);
style = SSM(sci, SCI_GETSTYLEAT, pos, 0);
//if (lexer != SCLEX_CPP && lexer != SCLEX_HTML && lexer != SCLEX_PASCAL) return FALSE; //if (lexer != SCLEX_CPP && lexer != SCLEX_HTML && lexer != SCLEX_PASCAL) return FALSE;
if (lexer == SCLEX_HTML && style == SCE_H_DEFAULT) return FALSE; if (lexer == SCLEX_HTML && style == SCE_H_DEFAULT) return FALSE;
if (lexer == SCLEX_CPP && (style == SCE_C_COMMENT || if (lexer == SCLEX_CPP && (style == SCE_C_COMMENT ||
@ -669,8 +670,13 @@ void sci_cb_show_macro_list(ScintillaObject *sci)
{ {
guint j, i; guint j, i;
const GPtrArray *tags; const GPtrArray *tags;
GPtrArray *ftags = g_ptr_array_sized_new(50); GPtrArray *ftags;
GString *words = g_string_sized_new(200); GString *words;
if (sci == NULL) return;
ftags = g_ptr_array_sized_new(50);
words = g_string_sized_new(200);
for (j = 0; j < app->tm_workspace->work_objects->len; j++) for (j = 0; j < app->tm_workspace->work_objects->len; j++)
{ {
@ -795,94 +801,6 @@ void sci_cb_auto_table(ScintillaObject *sci, gint pos)
} }
/**
* This routine will find an uri like http://www.example.com or file:///tmp/test.c
* @parm pos The position where to start looking for an URI
* @return the position where the URI starts, or -1 if no URI was found
*/
gint sci_cb_handle_uri(ScintillaObject *sci, gint pos)
{
gint lexer = SSM(sci, SCI_GETLEXER, 0, 0);
gint min, sel_start, sel_end, end_of_text, end_of_styling;
gint line = sci_get_line_from_position(sci, pos);
gint line_start = sci_get_position_from_line(sci, line);
gint line_end = line_start + sci_get_line_length(sci, line) - 1;
gchar sel[300], *begin, *cur, *uri;
// This may make sense only in certain languages
if ((lexer != SCLEX_HTML && lexer != SCLEX_XML))
return -1;
if (pos < 0) return -1;
if (SSM(sci, SCI_GETSTYLEAT, pos, 0) == SCE_H_VALUE || SSM(sci, SCI_GETSTYLEAT, pos, 0) == SCE_H_CDATA)
return -1;
// Grab some characters around pos
min = pos - 149;
if (min < 0) min = 0;
end_of_text = pos + 149;
if (end_of_text > sci_get_length(sci)) end_of_text = sci_get_length(sci);
sci_get_text_range(sci, min, end_of_text, sel);
sel[sizeof(sel) - 1] = '\0';
begin = &sel[0];
cur = &sel[149];
sel_start = pos;
while (cur > begin)
{
if (*cur == '>') break;
else if (*cur == ' ') break;
else if (*cur == '"') break;
else if (*cur == '=') break;
--cur;
--sel_start;
}
// stay in the current line
if (sel_start < line_start) sel_start = line_start - 1;
sel_end = sel_start++;
cur++;
while(cur > begin)
{
if (*cur == '\0') break;
else if (*cur == ' ') break;
else if (*cur == '"') break;
else if (*cur == '<') break;
else if (*cur == '>') break;
sel_end++;
cur++;
}
// stay in the current line
if (sel_end > line_end) sel_end = line_end - 1;
// check wether uri contains ://, otherwise give up
uri = g_malloc0(sel_end - sel_start + 1);
sci_get_text_range(sci, sel_start, sel_end, uri);
if (strstr(uri, "://") == NULL)
{
g_free(uri);
return -1;
}
g_free(uri);
end_of_styling = SSM(sci, SCI_GETENDSTYLED, 0, 0);
SSM(sci, SCI_STARTSTYLING, sel_start, 31);
SSM(sci, SCI_SETSTYLING, (sel_end - sel_start) + 1, SCE_H_QUESTION);
SSM(sci, SCI_STARTSTYLING, end_of_styling, 31);
link_start = sel_start;
link_end = sel_end + 1;
style = SSM(sci, SCI_GETSTYLEAT, pos, 0);
//geany_debug("pos: %d start: %d end: %d length: %d", pos, sel_start, sel_end, sel_end - sel_start);
return -1;
}
void sci_cb_do_comment(gint idx) void sci_cb_do_comment(gint idx)
{ {
gint first_line; gint first_line;
@ -890,7 +808,11 @@ void sci_cb_do_comment(gint idx)
gint x, i, line_start, line_len; gint x, i, line_start, line_len;
gchar sel[64], *co, *cc; gchar sel[64], *co, *cc;
gboolean break_loop = FALSE; gboolean break_loop = FALSE;
filetype *ft = doc_list[idx].file_type; filetype *ft;
if (idx == -1 || ! doc_list[idx].is_valid) return;
ft = doc_list[idx].file_type;
first_line = sci_get_line_from_position(doc_list[idx].sci, first_line = sci_get_line_from_position(doc_list[idx].sci,
sci_get_selection_start(doc_list[idx].sci)); sci_get_selection_start(doc_list[idx].sci));

View File

@ -176,6 +176,12 @@ void treeviews_prepare_openfiles(void)
tv.store_openfiles = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); tv.store_openfiles = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
gtk_tree_view_set_model(GTK_TREE_VIEW(tv.tree_openfiles), GTK_TREE_MODEL(tv.store_openfiles)); gtk_tree_view_set_model(GTK_TREE_VIEW(tv.tree_openfiles), GTK_TREE_MODEL(tv.store_openfiles));
// set policy settings for the scolledwindow around the treeview again, because glade
// doesn't keep the settings
gtk_scrolled_window_set_policy(
GTK_SCROLLED_WINDOW(lookup_widget(app->window, "scrolledwindow7")),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
renderer = gtk_cell_renderer_text_new(); renderer = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes(_("Open files"), renderer, "text", 0, NULL); column = gtk_tree_view_column_new_with_attributes(_("Open files"), renderer, "text", 0, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(tv.tree_openfiles), column); gtk_tree_view_append_column(GTK_TREE_VIEW(tv.tree_openfiles), column);