/* Remove Whitespace Lines */
gint
rmwhspln(ScintillaObject *sci, gint line_num, gint end_line_num)
{
	gint indent;                       /* indent position */
	gint changed = 0;                  /* number of lines removed */

	while(line_num <= end_line_num)    /* loop through lines */
	{
		indent = scintilla_send_message(sci,
									SCI_GETLINEINDENTPOSITION,
									line_num, 0);

		/* check if the posn of indentation is also the end of line posn */
		if(indent -
		   sci_get_position_from_line(sci, line_num) ==
		   sci_get_line_end_position (sci, line_num) -
		   sci_get_position_from_line(sci, line_num))
		{
			scintilla_send_message(sci,
					   SCI_DELETERANGE,
					   sci_get_position_from_line(sci, line_num),
					   sci_get_line_length(sci, line_num));

			line_num--;
			end_line_num--;
			changed++;
		}
		line_num++;

	}

	/* return the number of lines deleted */
	return -changed;
}
Exemple #2
0
/*
 * opens position in a editor 
 */
void editor_open_position(const gchar *filename, int line)
{
	GeanyDocument* doc = NULL;
	gboolean already_open = (doc = document_get_current()) && !strcmp(DOC_FILENAME(doc), filename);

	if (!already_open)
		doc = document_open_file(filename, FALSE, NULL, NULL);

	if (doc)
	{
		/* temporarily set debug caret policy */
		scintilla_send_message(doc->editor->sci, SCI_SETYCARETPOLICY, CARET_SLOP | CARET_JUMPS | CARET_EVEN, 3);

		sci_goto_line(doc->editor->sci, line - 1, TRUE);

		/* revert to default edit caret policy */
		scintilla_send_message(doc->editor->sci, SCI_SETYCARETPOLICY, CARET_EVEN, 0);

		scintilla_send_message(doc->editor->sci, SCI_SETFOCUS, TRUE, 0);
	}
	else
	{
		dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("Can't find a source file \"%s\""), filename);
	}
}
Exemple #3
0
static void create_selection(ScintillaObject *sci, int anchor, int anchor_space,
	gboolean rectangle)
{
	int cursor = sci_get_current_position(sci);
	int cursor_space = sci_get_cursor_space(sci);

	if (rectangle)
	{
		sci_set_selection_mode(sci, SC_SEL_RECTANGLE);
		sci_set_anchor(sci, anchor);
		/* sci_set_current_position() sets anchor = cursor, bypass */
		scintilla_send_message(sci, SCI_SETCURRENTPOS, cursor, 0);
	}
	else
	{
		sci_set_selection_mode(sci, SC_SEL_STREAM);
		scintilla_send_message(sci, SCI_SETSEL, anchor, cursor);
	}

	sci_set_anchor_space(sci, anchor_space);
	sci_set_cursor_space(sci, cursor_space);

	/* SCI bug: CANCEL may reduce a rectangle selection to a single line */
	if (rectangle)
		sci_set_selection_mode(sci, SC_SEL_RECTANGLE);
	else
		sci_send_command(sci, SCI_CANCEL);
}
Exemple #4
0
static gboolean on_mouse_leave(GtkWidget *widget, GdkEvent *event, gpointer user_data)
{
	ScintillaObject *so = (ScintillaObject*)widget;
	if (scintilla_send_message (so, SCI_CALLTIPACTIVE, 0, 0))
	{
		g_signal_handler_disconnect(G_OBJECT(widget), leave_signal);
		scintilla_send_message (so, SCI_CALLTIPCANCEL, 0, 0);
	}
	return FALSE;
}
static void highlight_tag(ScintillaObject *sci, gint openingBracket,
                          gint closingBracket, gint color)
{
    scintilla_send_message(sci, SCI_SETINDICATORCURRENT, INDICATOR_TAGMATCH, 0);
    scintilla_send_message(sci, SCI_INDICSETSTYLE,
                            INDICATOR_TAGMATCH, INDIC_ROUNDBOX);
    scintilla_send_message(sci, SCI_INDICSETFORE, INDICATOR_TAGMATCH, rgb2bgr(color));
    scintilla_send_message(sci, SCI_INDICSETALPHA, INDICATOR_TAGMATCH, 60);
    scintilla_send_message(sci, SCI_INDICATORFILLRANGE,
                            openingBracket, closingBracket-openingBracket+1);
}
Exemple #6
0
void prefs_apply(GeanyDocument *doc)
{
	gint i;
	ScintillaObject *sci = doc->editor->sci;
	MarkerStyle *style = pref_marker_styles;

	for (i = pref_sci_marker_first; i < pref_sci_marker_first + MARKER_COUNT; i++, style++)
	{
		scintilla_send_message(sci, SCI_MARKERDEFINE, i, style->mark);
		scintilla_send_message(sci, SCI_MARKERSETFORE, i, style->fore);
		scintilla_send_message(sci, SCI_MARKERSETBACK, i, style->back);
		scintilla_send_message(sci, SCI_MARKERSETALPHA, i, style->alpha);
	}
}
static void DeleteMarker(GeanyDocument* doc,gint bookmarkNumber,gint markerNumber)
{
	guint32 *markers;
	ScintillaObject *sci=doc->editor->sci;

	/* remove marker */
	scintilla_send_message(sci,SCI_MARKERDELETEALL,markerNumber,0);
	scintilla_send_message(sci,SCI_MARKERDEFINE,markerNumber,SC_MARK_AVAILABLE);

	/* update record of which markers are being used */
	markers=GetMarkersUsed(sci);
	(*markers)-=1<<markerNumber;
	g_object_set_data(G_OBJECT(sci),"Geany_Numbered_Bookmarks_Used",(gpointer)markers);
}
Exemple #8
0
/* geany_xml_encode_selection
 * 
 * Encode the XML entities in the current selection.
 */
void geany_xml_encode_selection()
{
  GeanyDocument* document = document_get_current();
  if (document)
  {
    ScintillaObject* sci = document->editor->sci;
    
    unsigned long sel_beg = scintilla_send_message(sci, SCI_GETSELECTIONSTART, 0, 0);
    unsigned long sel_end = scintilla_send_message(sci, SCI_GETSELECTIONEND, 0, 0);
    
    int replaced = geany_xml_encode(document, sel_beg, sel_end);
    
    // Display notification in status area.
    geany_xml_encode_notify(document, replaced);
  }
}
/* Remove Empty Lines */
gint
rmemtyln(ScintillaObject *sci, gint line_num, gint end_line_num)
{
	gint  changed = 0;     /* number of lines removed */

	while(line_num <= end_line_num)    /* loop through lines */
	{
		/* check if the first posn of the line is also the end of line posn */
		if(sci_get_position_from_line(sci, line_num) ==
		   sci_get_line_end_position (sci, line_num))
		{
			scintilla_send_message(sci,
					   SCI_DELETERANGE,
					   sci_get_position_from_line(sci, line_num),
					   sci_get_line_length(sci, line_num));

			line_num--;
			end_line_num--;
			changed++;
		}
		line_num++;
	}

	/* return the number of lines deleted */
	return -changed;
}
static void ApplyBookmarks(GeanyDocument* doc,FileData *fd)
{
	gint i,iLineCount,m;
	GtkWidget *dialog;
	ScintillaObject* sci=doc->editor->sci;

	iLineCount=scintilla_send_message(sci,SCI_GETLINECOUNT,0,0);

	for(i=0;i<10;i++)
		if(fd->iBookmark[i]!=-1 && fd->iBookmark[i]<iLineCount)
		{
			m=NextFreeMarker(doc);
			/* if run out of markers report this */
			if(m==-1)
			{
				dialog=gtk_message_dialog_new(GTK_WINDOW(geany->main_widgets->window),
				                              GTK_DIALOG_DESTROY_WITH_PARENT,
				                              GTK_MESSAGE_ERROR,GTK_BUTTONS_NONE,
_("Unable to apply all markers to '%s' as all being used."),
				                              doc->file_name);
				gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Okay"),GTK_RESPONSE_OK);
				gtk_dialog_run(GTK_DIALOG(dialog));
				gtk_widget_destroy(dialog);
				return;
			}

			/* otherwise ok to set marker */
			SetMarker(doc,i,m,fd->iBookmark[i]);
		}
}
Exemple #11
0
static void on_sci_notify(ScintillaObject *sci, gint param,
                          SCNotification *nt, gpointer data)
{
    gint line;

    switch (nt->nmhdr.code)
    {
    /* adapted from editor.c: on_margin_click() */
    case SCN_MARGINCLICK:
        /* left click to marker margin toggles marker */
        if (nt->margin == 1)
        {
            gboolean set;
            gint marker = 1;

            line = sci_get_line_from_position(sci, nt->position);
            set = sci_is_marker_set_at_line(sci, line, marker);
            if (!set)
                sci_set_marker_at_line(sci, line, marker);
            else
                sci_delete_marker_at_line(sci, line, marker);
        }
        /* left click on the folding margin to toggle folding state of current line */
        if (nt->margin == 2)
        {
            line = sci_get_line_from_position(sci, nt->position);
            scintilla_send_message(sci, SCI_TOGGLEFOLD, line, 0);
        }
        break;

    default:
        break;
    }
}
Exemple #12
0
static gboolean on_query_tooltip(G_GNUC_UNUSED GtkWidget *widget, gint x, gint y,
	gboolean keyboard_mode, GtkTooltip *tooltip, GeanyEditor *editor)
{
	gint pos = keyboard_mode ? sci_get_current_position(editor->sci) :
		scintilla_send_message(editor->sci, SCI_POSITIONFROMPOINT, x, y);

	if (pos >= 0)
	{
		if (pos == last_pos)
		{
			gtk_tooltip_set_text(tooltip, output);
			return show;
		}
		else if (pos != peek_pos)
		{
			if (query_id)
				g_source_remove(query_id);
			else
				scid_gen++;

			peek_pos = pos;
			query_id = plugin_timeout_add(geany_plugin, pref_tooltips_send_delay * 10,
				tooltip_launch, editor);
		}
	}

	return FALSE;
}
Exemple #13
0
sptr_t IupScintillaSendMessage(Ihandle* ih, unsigned int iMessage, uptr_t wParam, sptr_t lParam)
{
#ifdef GTK
  return scintilla_send_message(SCINTILLA(ih->handle), iMessage, wParam, lParam);
#else
  return SendMessage(ih->handle, iMessage, wParam, lParam);
#endif
}
Exemple #14
0
gint sc_speller_process_line(GeanyDocument *doc, gint line_number, const gchar *line)
{
	gint pos_start, pos_end;
	gint wstart, wend;
	GString *str;
	gint suggestions_found = 0;
	gchar c;

	g_return_val_if_fail(sc_speller_dict != NULL, 0);
	g_return_val_if_fail(doc != NULL, 0);
	g_return_val_if_fail(line != NULL, 0);

	str = g_string_sized_new(256);

	pos_start = sci_get_position_from_line(doc->editor->sci, line_number);
	pos_end = sci_get_position_from_line(doc->editor->sci, line_number + 1);

	while (pos_start < pos_end)
	{
		wstart = scintilla_send_message(doc->editor->sci, SCI_WORDSTARTPOSITION, pos_start, TRUE);
		wend = scintilla_send_message(doc->editor->sci, SCI_WORDENDPOSITION, wstart, FALSE);
		if (wstart == wend)
			break;
		c = sci_get_char_at(doc->editor->sci, wstart);
		/* hopefully it's enough to check for these both */
		if (ispunct(c) || isspace(c))
		{
			pos_start++;
			continue;
		}

		/* ensure the string has enough allocated memory */
		if (str->len < (guint)(wend - wstart))
			g_string_set_size(str, wend - wstart);

		sci_get_text_range(doc->editor->sci, wstart, wend, str->str);

		suggestions_found += sc_speller_check_word(doc, line_number, str->str, wstart, wend);

		pos_start = wend + 1;
	}

	g_string_free(str, TRUE);
	return suggestions_found;
}
Exemple #15
0
/*
 * 	Occures on document opening.
 * 	Used to set breaks markers 
 */
void on_document_open(GObject *obj, GeanyDocument *doc, gpointer user_data)
{
	/*set markers*/
	markers_set_for_document(doc->editor->sci);

	/*set dwell interval*/
	scintilla_send_message(doc->editor->sci, SCI_SETMOUSEDWELLTIME, 500, 0);

	/* set tab size for calltips */
	scintilla_send_message(doc->editor->sci, SCI_CALLTIPUSESTYLE, 20, (long)NULL);

	/* set breakpoint and frame markers */
	set_markers_for_file(DOC_FILENAME(doc));

	/* if debug is active - tell the debug module that a file was opened */
	if (DBS_IDLE != debug_get_state())
		debug_on_file_open(doc);
}
Exemple #16
0
/* line numbers visibility */
static void set_line_numbers(ScintillaObject * sci, gboolean set)
{
    if (set)
    {
        gchar tmp_str[15];
        gint len = scintilla_send_message(sci, SCI_GETLINECOUNT, 0, 0);
        gint width;

        g_snprintf(tmp_str, 15, "_%d", len);
        width = scintilla_send_message(sci, SCI_TEXTWIDTH, STYLE_LINENUMBER, (sptr_t) tmp_str);
        scintilla_send_message(sci, SCI_SETMARGINWIDTHN, 0, width);
        scintilla_send_message(sci, SCI_SETMARGINSENSITIVEN, 0, FALSE); /* use default behaviour */
    }
    else
    {
        scintilla_send_message(sci, SCI_SETMARGINWIDTHN, 0, 0);
    }
}
Exemple #17
0
/*
 * removes all markers from GeanyDocument
 */
void markers_remove_all(GeanyDocument *doc)
{
	static int markers[] = { M_BP_ENABLED, M_BP_DISABLED, M_BP_CONDITIONAL, M_CI_BACKGROUND, M_CI_ARROW, M_FRAME };
	int i = 0, size = sizeof(markers) / sizeof(int);
	for (; i < size; i++)
	{
		scintilla_send_message(doc->editor->sci, SCI_MARKERDELETEALL, markers[i], 0);
	}
}
Exemple #18
0
/*
 * removes frame marker
 */
void markers_remove_frame(char* file, int line)
{
	GeanyDocument *doc = document_find_by_filename(file);
	if (doc)
	{
		sci_delete_marker_at_line(doc->editor->sci, line - 1, M_FRAME);
		scintilla_send_message(doc->editor->sci, SCI_SETFOCUS, TRUE, 0);
	}
}
Exemple #19
0
/*
 * removes current instruction marker
 */
void markers_remove_current_instruction(char* file, int line)
{
	GeanyDocument *doc = document_find_by_filename(file);
	if (doc)
	{
		sci_delete_marker_at_line(doc->editor->sci, line - 1, M_CI_ARROW);
		sci_delete_marker_at_line(doc->editor->sci, line - 1, M_CI_BACKGROUND);
		scintilla_send_message(doc->editor->sci, SCI_SETFOCUS, TRUE, 0);
	}
}
Exemple #20
0
static void menu_addword_item_activate_cb(GtkMenuItem *menuitem, gpointer gdata)
{
    gint startword, endword, i, doc_len;
    ScintillaObject *sci;
    GString *str;
    gboolean ignore = GPOINTER_TO_INT(gdata);

    if (clickinfo.doc == NULL || clickinfo.word == NULL || clickinfo.pos == -1)
        return;

    /* if we ignore the word, we add it to the current session, to ignore it
     * also for further checks*/
    if (ignore)
        sc_speller_add_word_to_session(clickinfo.word);
    /* if we do not ignore the word, we add the word to the personal dictionary */
    else
        sc_speller_add_word(clickinfo.word);

    /* Remove all indicators on the added/ignored word */
    sci = clickinfo.doc->editor->sci;
    str = g_string_sized_new(256);
    doc_len = sci_get_length(sci);
    for (i = 0; i < doc_len; i++)
    {
        startword = scintilla_send_message(sci, SCI_INDICATORSTART, 0, i);
        if (startword >= 0)
        {
            endword = scintilla_send_message(sci, SCI_INDICATOREND, 0, startword);
            if (startword == endword)
                continue;

            if (str->len < (guint)(endword - startword + 1))
                str = g_string_set_size(str, endword - startword + 1);
            sci_get_text_range(sci, startword, endword, str->str);

            if (strcmp(str->str, clickinfo.word) == 0)
                sci_indicator_clear(sci, startword, endword - startword);

            i = endword;
        }
    }
    g_string_free(str, TRUE);
}
static void SetMarker(GeanyDocument* doc,gint bookmarkNumber,gint markerNumber,gint line)
{
	guint32 *markers;
	FileData *fd;
	ScintillaObject *sci=doc->editor->sci;

	/* insert new marker */
	scintilla_send_message(sci,SCI_MARKERDEFINEPIXMAP,markerNumber,
	                       (glong)(aszMarkerImages[bookmarkNumber]));
	scintilla_send_message(sci,SCI_MARKERADD,line,markerNumber);

	/* update record of which bookmark uses which marker */
	fd=GetFileData(doc->file_name);
	fd->iBookmarkMarkerUsed[bookmarkNumber]=markerNumber;

	/* update record of which markers are being used */
	markers=GetMarkersUsed(sci);
	(*markers)|=1<<markerNumber;
	g_object_set_data(G_OBJECT(sci),"Geany_Numbered_Bookmarks_Used",(gpointer)markers);
}
Exemple #22
0
void on_toggle_case1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
	GeanyDocument *doc = document_get_current();
	ScintillaObject *sci;
	gchar *text;
	gboolean keep_sel = TRUE;

	g_return_if_fail(doc != NULL);

	sci = doc->editor->sci;
	if (! sci_has_selection(sci))
	{
		keybindings_send_command(GEANY_KEY_GROUP_SELECT, GEANY_KEYS_SELECT_WORD);
		keep_sel = FALSE;
	}

	/* either we already had a selection or we created one for current word */
	if (sci_has_selection(sci))
	{
		gchar *result = NULL;
		gint cmd = SCI_LOWERCASE;
		gboolean rectsel = (gboolean) scintilla_send_message(sci, SCI_SELECTIONISRECTANGLE, 0, 0);

		text = sci_get_selection_contents(sci);

		if (utils_str_has_upper(text))
		{
			if (rectsel)
				cmd = SCI_LOWERCASE;
			else
				result = g_utf8_strdown(text, -1);
		}
		else
		{
			if (rectsel)
				cmd = SCI_UPPERCASE;
			else
				result = g_utf8_strup(text, -1);
		}

		if (result != NULL)
		{
			sci_replace_sel(sci, result);
			g_free(result);
			if (keep_sel)
				sci_set_selection_start(sci, sci_get_current_position(sci) - strlen(text));
		}
		else
			sci_send_command(sci, cmd);

		g_free(text);

	}
}
Exemple #23
0
static void sync_to_current(ScintillaObject *sci, ScintillaObject *current)
{
    gpointer sdoc;
    gint pos;

    /* set the new sci widget to view the existing Scintilla document */
    sdoc = (gpointer) scintilla_send_message(current, SCI_GETDOCPOINTER, 0, 0);
    scintilla_send_message(sci, SCI_SETDOCPOINTER, 0, (sptr_t) sdoc);

    highlighting_set_styles(sci, edit_window.editor->document->file_type);
    pos = sci_get_current_position(current);
    sci_set_current_position(sci, pos, TRUE);

    /* override some defaults */
    set_line_numbers(sci, geany->editor_prefs->show_linenumber_margin);
    /* marker margin */
    scintilla_send_message(sci, SCI_SETMARGINWIDTHN, 1,
                           scintilla_send_message(current, SCI_GETMARGINWIDTHN, 1, 0));
    if (!geany->editor_prefs->folding)
        scintilla_send_message(sci, SCI_SETMARGINWIDTHN, 2, 0);
}
Exemple #24
0
static gboolean resync_readonly(G_GNUC_UNUSED gpointer gdata)
{
	guint i;

	foreach_document(i)
	{
		documents[i]->readonly = scintilla_send_message(documents[i]->editor->sci,
			SCI_GETREADONLY, 0, 0);
	}

	resync_id = 0;
	return FALSE;
}
Exemple #25
0
static void menu_suggestion_item_activate_cb(GtkMenuItem *menuitem, gpointer gdata)
{
    const gchar *sugg;
    gint startword, endword;
    ScintillaObject *sci = clickinfo.doc->editor->sci;

    g_return_if_fail(clickinfo.doc != NULL && clickinfo.pos != -1);

    startword = scintilla_send_message(sci, SCI_WORDSTARTPOSITION, clickinfo.pos, 0);
    endword = scintilla_send_message(sci, SCI_WORDENDPOSITION, clickinfo.pos, 0);

    if (startword != endword)
    {
        gchar *word;

        sci_set_selection_start(sci, startword);
        sci_set_selection_end(sci, endword);

        /* retrieve the old text */
        word = g_malloc(sci_get_selected_text_length(sci) + 1);
        sci_get_selected_text(sci, word);

        /* retrieve the new text */
        sugg = gtk_label_get_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN(menuitem))));

        /* replace the misspelled word with the chosen suggestion */
        sci_replace_sel(sci, sugg);

        /* store the replacement for future checks */
        sc_speller_store_replacement(word, sugg);

        /* remove indicator */
        sci_indicator_clear(sci, startword, endword - startword);

        g_free(word);
    }
}
Exemple #26
0
void geanypg_load_buffer(gpgme_data_t * buffer)
{
    /* gpgme_data_new_from_mem(buffer, text, size, 0); */
    GeanyDocument * doc = document_get_current();
    char * data = NULL;
    unsigned long size = 0;
    if (sci_has_selection(doc->editor->sci))
    {
        size = scintilla_send_message(doc->editor->sci, SCI_GETSELTEXT, 0, 0) - 1;
        data = (char *) malloc(size + 1);
        scintilla_send_message(doc->editor->sci, SCI_GETSELTEXT, 0, (sptr_t)data);
        gpgme_data_new_from_mem(buffer, data, size, 1);
    }
    else
    {
        size = scintilla_send_message(doc->editor->sci, SCI_GETLENGTH, 0, 0);
        data = (char *) malloc(size + 1);
        scintilla_send_message(doc->editor->sci, SCI_GETTEXT, (uptr_t)(size + 1), (sptr_t)data);
        gpgme_data_new_from_mem(buffer, data, size, 1);
    }
    if (data) /* if there is no text data may still be NULL */
        free(data);
    gpgme_data_set_encoding(*buffer, GPGME_DATA_ENCODING_BINARY);
}
Exemple #27
0
void geanypg_write_file(FILE * file)
{
#define BUFSIZE 2048
    unsigned long size;
    char buffer[BUFSIZE] = {0};
    GeanyDocument * doc = document_get_current();
    sci_start_undo_action(doc->editor->sci);
    if (sci_has_selection(doc->editor->sci))
    {   /* replace selected text
         * clear selection, cursor should be at the end or beginneng of the selection */
        scintilla_send_message(doc->editor->sci, SCI_REPLACESEL, 0, (sptr_t)"");
        while ((size = fread(buffer, 1, BUFSIZE, file)))
            /* add at the cursor */
            scintilla_send_message(doc->editor->sci, SCI_ADDTEXT, (uptr_t) size, (sptr_t) buffer);
    }
    else
    {   /* replace complete document */
        scintilla_send_message(doc->editor->sci, SCI_CLEARALL, 0, 0);
        while ((size = fread(buffer, 1, BUFSIZE, file)))
            scintilla_send_message(doc->editor->sci, SCI_APPENDTEXT, (uptr_t) size, (sptr_t) buffer);
    }
    sci_end_undo_action(doc->editor->sci);
#undef BUFSIZE
}
static PyObject *
Scintilla_send_message(Scintilla *self, PyObject *args, PyObject *kwargs)
{
	gint msg;
	glong uptr = 0, sptr = 0, ret;
	static gchar *kwlist[] = { "msg", "lparam", "wparam", NULL };

	SCI_RET_IF_FAIL(self);

	if (PyArg_ParseTupleAndKeywords(args, kwargs, "i|ll", kwlist, &msg, &uptr, &sptr))
	{
		ret = scintilla_send_message(self->sci, msg, uptr, sptr);
		return Py_BuildValue("l", ret);
	}

	Py_RETURN_NONE;
}
Exemple #29
0
/*
 * sets markers for a scintilla document
 */
void markers_set_for_document(ScintillaObject *sci)
{
	/* enabled breakpoint */
	scintilla_send_message(sci, SCI_MARKERDEFINEPIXMAP, M_BP_ENABLED, (long)breakpoint_xpm);
	
	/* disabled breakpoint */ 
	scintilla_send_message(sci, SCI_MARKERDEFINEPIXMAP, M_BP_DISABLED, (long)breakpoint_disabled_xpm);

	/* conditional breakpoint */
	scintilla_send_message(sci, SCI_MARKERDEFINEPIXMAP, M_BP_CONDITIONAL, (long)breakpoint_condition_xpm);

	/* currect instruction background */
	scintilla_send_message(sci, SCI_MARKERDEFINE, M_CI_BACKGROUND, SC_MARK_BACKGROUND);
	scintilla_send_message(sci, SCI_MARKERSETBACK, M_CI_BACKGROUND, YELLOW);
	scintilla_send_message(sci, SCI_MARKERSETFORE, M_CI_BACKGROUND, YELLOW);
	scintilla_send_message(sci, SCI_MARKERSETALPHA, M_CI_BACKGROUND, 75);

	/* currect instruction arrow */
	scintilla_send_message(sci, SCI_MARKERDEFINEPIXMAP, M_CI_ARROW, (long)frame_current_xpm);

	/* frame marker current */
	scintilla_send_message(sci, SCI_MARKERDEFINEPIXMAP, M_FRAME, (long)frame_xpm);
}
Exemple #30
0
gint sc_speller_process_line(GeanyDocument *doc, gint line_number)
{
	gint pos_start, pos_end;
	gint wstart, wend;
	gint suggestions_found = 0;
	gint wordchars_len;
	gchar *wordchars;

	g_return_val_if_fail(sc_speller_dict != NULL, 0);
	g_return_val_if_fail(doc != NULL, 0);

	/* add ' (single quote) temporarily to wordchars
	 * to be able to check for "doesn't", "isn't" and similar */
	wordchars_len = scintilla_send_message(doc->editor->sci, SCI_GETWORDCHARS, 0, 0);
	wordchars = g_malloc0(wordchars_len + 2); /* 2 = temporarily added "'" and "\0" */
	scintilla_send_message(doc->editor->sci, SCI_GETWORDCHARS, 0, (sptr_t)wordchars);
	if (! strchr(wordchars, '\''))
	{
		/* temporarily add "'" to the wordchars */
		wordchars[wordchars_len] = '\'';
		scintilla_send_message(doc->editor->sci, SCI_SETWORDCHARS, 0, (sptr_t)wordchars);
	}

	pos_start = sci_get_position_from_line(doc->editor->sci, line_number);
	pos_end = sci_get_position_from_line(doc->editor->sci, line_number + 1);

	while (pos_start < pos_end)
	{
		gchar *word;

		wstart = scintilla_send_message(doc->editor->sci, SCI_WORDSTARTPOSITION, pos_start, TRUE);
		wend = scintilla_send_message(doc->editor->sci, SCI_WORDENDPOSITION, wstart, FALSE);
		if (wstart == wend)
			break;

		word = sci_get_contents_range(doc->editor->sci, wstart, wend);

		suggestions_found += sc_speller_check_word(doc, line_number, word, wstart, wend);

		pos_start = wend + 1;

		g_free(word);
	}

	/* reset wordchars for the current document */
	wordchars[wordchars_len] = '\0';
	scintilla_send_message(doc->editor->sci, SCI_SETWORDCHARS, 0, (sptr_t)wordchars);

	g_free(wordchars);
	return suggestions_found;
}