gboolean html_engine_end_of_line (HTMLEngine *engine) { gboolean retval; g_return_val_if_fail (engine != NULL, FALSE); g_return_val_if_fail (HTML_IS_ENGINE (engine), FALSE); html_engine_hide_cursor (engine); retval = html_cursor_end_of_line (engine->cursor, engine); html_engine_update_focus_if_necessary (engine, engine->cursor->object, engine->cursor->offset); html_engine_show_cursor (engine); html_engine_update_selection_if_necessary (engine); return retval; }
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); }
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; }