コード例 #1
0
void sc_speller_check_document(GeanyDocument *doc)
{
	gint i;
	gint first_line, last_line;
	gchar *dict_string = NULL;
	gint suggestions_found = 0;

	g_return_if_fail(sc_speller_dict != NULL);
	g_return_if_fail(doc != NULL);

	ui_progress_bar_start(_("Checking"));

	enchant_dict_describe(sc_speller_dict, dict_describe, &dict_string);

	if (sci_has_selection(doc->editor->sci))
	{
		first_line = sci_get_line_from_position(
			doc->editor->sci, sci_get_selection_start(doc->editor->sci));
		last_line = sci_get_line_from_position(
			doc->editor->sci, sci_get_selection_end(doc->editor->sci));

		if (sc_info->use_msgwin)
			msgwin_msg_add(COLOR_BLUE, -1, NULL,
				_("Checking file \"%s\" (lines %d to %d using %s):"),
				DOC_FILENAME(doc), first_line + 1, last_line + 1, dict_string);
		g_message("Checking file \"%s\" (lines %d to %d using %s):",
			DOC_FILENAME(doc), first_line + 1, last_line + 1, dict_string);
	}
	else
	{
		first_line = 0;
		last_line = sci_get_line_count(doc->editor->sci);
		if (sc_info->use_msgwin)
			msgwin_msg_add(COLOR_BLUE, -1, NULL, _("Checking file \"%s\" (using %s):"),
				DOC_FILENAME(doc), dict_string);
		g_message("Checking file \"%s\" (using %s):", DOC_FILENAME(doc), dict_string);
	}
	g_free(dict_string);

	if (first_line == last_line)
	{
		suggestions_found += sc_speller_process_line(doc, first_line);
	}
	else
	{
		for (i = first_line; i < last_line; i++)
		{
			suggestions_found += sc_speller_process_line(doc, i);

			/* process other GTK events to keep the GUI being responsive */
			while (g_main_context_iteration(NULL, FALSE));
		}
	}
	if (suggestions_found == 0 && sc_info->use_msgwin)
		msgwin_msg_add(COLOR_BLUE, -1, NULL, _("The checked text is spelled correctly."));

	ui_progress_bar_stop();
}
コード例 #2
0
ファイル: gui.c プロジェクト: AtalAkbari/geany-plugins
static gboolean check_lines(gpointer data)
{
    GeanyDocument *doc = check_line_data.doc;

    /* since we're in an timeout callback, the document may have been closed */
    if (DOC_VALID (doc))
    {
        gchar *line;
        gint line_number = check_line_data.line_number;
        gint line_count = check_line_data.line_count;
        gint i;

        for (i = 0; i < line_count; i++)
        {
            line = sci_get_line(doc->editor->sci, line_number);
            indicator_clear_on_line(doc, line_number);
            if (sc_speller_process_line(doc, line_number, line) != 0)
            {
                if (sc_info->use_msgwin)
                    msgwin_switch_tab(MSG_MESSAGE, FALSE);
            }
            g_free(line);
        }
    }
    check_line_data.check_while_typing_idle_source_id = 0;
    return FALSE;
}