Пример #1
0
gboolean
html_engine_backward_word (HTMLEngine *e)
{
	gboolean rv = FALSE;

	g_return_val_if_fail (e != NULL, FALSE);
	g_return_val_if_fail (HTML_IS_ENGINE (e), FALSE);

	html_engine_hide_cursor (e);
	while (!g_unichar_isalnum (html_cursor_get_prev_char (e->cursor)) && html_cursor_backward (e->cursor, e))
		rv = TRUE;
	while (g_unichar_isalnum (html_cursor_get_prev_char (e->cursor)) && html_cursor_backward (e->cursor, e))
		rv = TRUE;
	html_engine_update_focus_if_necessary (e, e->cursor->object, e->cursor->offset);
	html_engine_show_cursor (e);
	html_engine_update_selection_if_necessary (e);

	return rv;
}
Пример #2
0
void
html_engine_insert_table_1_1 (HTMLEngine *e)
{
	HTMLObject    *table;

	table = html_table_new (0, 100, 1, 2, 1);

	html_table_add_cell (HTML_TABLE (table), html_engine_new_cell (e, HTML_TABLE (table)));

	html_engine_append_object (e, table, 2);
	html_cursor_backward (e->cursor, e);
	html_engine_table_set_align (e, (HTMLTable *) table, HTML_HALIGN_CENTER);
}
Пример #3
0
static void
backward_before_row (HTMLEngine *e,
                     HTMLTable *table,
                     gint row)
{
	HTMLObject *cell;

	do {
		if (!html_cursor_backward (e->cursor, e))
			return;
		cell = html_cursor_child_of (e->cursor, HTML_OBJECT (table));
	} while (cell && HTML_IS_TABLE_CELL (cell) && HTML_TABLE_CELL (cell)->row >= row);
}
Пример #4
0
void
html_engine_delete_table (HTMLEngine *e)
{
	HTMLTable *table;

	html_engine_disable_selection (e);

	table = html_engine_get_table (e);

	if (!table)
		return;
	while (e->cursor->object != HTML_OBJECT (table) || e->cursor->offset)
		html_cursor_backward (e->cursor, e);
	html_engine_set_mark (e);
	html_cursor_end_of_line (e->cursor, e);
	html_engine_delete (e);
}
Пример #5
0
static gint test_level_1 (GtkHTML *html)
{
	gint i, total_len = 0;

	set_format (html, FALSE);

	srand (2);

	for (i = 0; i < 200; i ++) {
		gint j, len = 1 + (gint) (10.0*rand()/(RAND_MAX+1.0));
		gchar word [12];

		for (j = 0; j < len; j ++)
			word [j] = 'a' + (gint) (26.0*rand()/(RAND_MAX+1.0));
		word [len] = ' ';
		word [len + 1] = 0;
		total_len += len + 1;

		html_engine_insert_text (html->engine, word, -1);
	}

	while (html_cursor_backward (html->engine->cursor, html->engine))
		;

	if (html->engine->cursor->position != 0 || html->engine->cursor->offset != 0)
		return FALSE;

	for (i = 0; i < 1000; i ++) {
		gint j, new_pos, pos, len;

		len = 1 + (gint) (120.0*rand()/(RAND_MAX+1.0));
		pos = MAX (0, (gint) (((double) (total_len - len))*rand()/(RAND_MAX+1.0)));

		printf ("step: %d pos: %d len: %d\n", i, pos, len);

		switch ((gint) (10.0*rand()/(RAND_MAX+1.0))) {
		case 0:
			/* cut'n'paste */
			printf ("cut'n'paste\n");
			html_cursor_jump_to_position (html->engine->cursor, html->engine, pos);
			html_engine_set_mark (html->engine);
			html_cursor_jump_to_position (html->engine->cursor, html->engine, pos + len);
			html_engine_cut (html->engine);

			new_pos = (gint) (((double) (total_len - len))*rand()/(RAND_MAX+1.0));

			html_cursor_jump_to_position (html->engine->cursor, html->engine, new_pos);
			html_engine_paste (html->engine);
			break;
		case 1:
			/* insert text */
			printf ("insert text\n");
			html_cursor_jump_to_position (html->engine->cursor, html->engine, pos);
			for (j = 0; j < len; j ++) {
				gint et = (gint) (10.0*rand()/(RAND_MAX+1.0));
				if (et == 0)
					gtk_html_command (html, "insert-tab");
				else {
					gchar ch [2];

					if (et == 1)
						ch [0] = ' ';
					else
						ch [0] = 'a' + (gint) (26.0*rand()/(RAND_MAX+1.0));
					ch [1] = 0;
					html_engine_insert_text (html->engine, ch, 1);
				}
			}
			total_len += len;
			break;
		case 2:
			/* delete text */
			printf ("delete text\n");
			html_cursor_jump_to_position (html->engine->cursor, html->engine, pos + len);
			for (j = 0; j < len; j++) {
				gtk_html_command (html, "delete");
			}
			total_len -= len;
			break;
		case 3:
			/* undo */
			printf ("undo\n");
			for (j = 0; j < len; j ++) {
				html_engine_undo (html->engine);
			}
			break;
		case 4:
			/* redo */
			printf ("redo\n");
			for (j = 0; j < len; j ++) {
				html_engine_redo (html->engine);
			}
			break;
		case 5:
			/* cut'n'quoted paste */
			printf ("cut'n'quoted paste\n");
			html_cursor_jump_to_position (html->engine->cursor, html->engine, pos);
			html_engine_set_mark (html->engine);
			html_cursor_jump_to_position (html->engine->cursor, html->engine, pos + len);
			gtk_html_cut (html);

			new_pos = (gint) (((double) (total_len - len))*rand()/(RAND_MAX+1.0));

			html_cursor_jump_to_position (html->engine->cursor, html->engine, new_pos);
			gtk_html_paste (html, TRUE);
			break;
		case 6:
			/* left */
			printf ("left\n");
			for (j = 0; j < 5*len; j ++) {
				html_cursor_left (html->engine->cursor, html->engine);
			}
			break;
		case 7:
			/* right */
			printf ("right\n");
			for (j = 0; j < 5*len; j ++) {
				html_cursor_right (html->engine->cursor, html->engine);
			}
			break;
		case 8:
			/* bol */
			printf ("beginning of line\n");
			html_cursor_beginning_of_line (html->engine->cursor, html->engine);
			break;
		case 9:
			/* eol */
			printf ("end of line\n");
			html_cursor_end_of_line (html->engine->cursor, html->engine);
			break;
		}

		html_engine_thaw_idle_flush (html->engine);

		while (html_cursor_backward (html->engine->cursor, html->engine))
			;
		if (html->engine->cursor->position != 0 || html->engine->cursor->offset != 0)
			return FALSE;
	}

	while (html_cursor_backward (html->engine->cursor, html->engine))
		;

	if (html->engine->cursor->position != 0 || html->engine->cursor->offset != 0)
		return FALSE;

	return TRUE;
}