public static void nk_textedit_discard_redo(NkTextUndoState state) { ulong num; int k = (int)(99 - 1); if (state.RedoPoint <= k) { if ((state.UndoRec[k].char_storage) >= (0)) { int n = (int)(state.UndoRec[k].insert_length); int i; state.RedoCharPoint = ((short)(state.RedoCharPoint + n)); num = ((ulong)(999 - state.RedoCharPoint)); nk_memcopy((char *)state.UndoChar + state.RedoCharPoint, (char *)state.UndoChar + state.RedoCharPoint - n, (ulong)(num * sizeof(char))); for (i = (int)(state.RedoPoint); (i) < (k); ++i) { if ((((nk_text_undo_record *)state.UndoRec + i)->char_storage) >= (0)) { ((nk_text_undo_record *)state.UndoRec + i)->char_storage = ((short)(((nk_text_undo_record *)state.UndoRec + i)->char_storage + n)); } } } ++state.RedoPoint; num = ((ulong)(99 - state.RedoPoint)); if ((num) != 0) { nk_memcopy((nk_text_undo_record *)state.UndoRec + state.RedoPoint - 1, (nk_text_undo_record *)state.UndoRec + state.RedoPoint, (ulong)(num * (ulong)sizeof(nk_text_undo_record))); } } }
public static void nk_textedit_discard_undo(NkTextUndoState state) { if ((state.UndoPoint) > (0)) { if ((state.UndoRec[0].char_storage) >= (0)) { int n = (int)(state.UndoRec[0].insert_length); int i; state.UndoCharPoint = ((short)(state.UndoCharPoint - n)); nk_memcopy(state.UndoChar, (char *)(char *)state.UndoChar + n, (ulong)((ulong)(state.UndoCharPoint) * sizeof(uint))); for (i = (int)(0); (i) < (state.UndoPoint); ++i) { if ((((nk_text_undo_record *)state.UndoRec + i)->char_storage) >= (0)) { ((nk_text_undo_record *)state.UndoRec + i)->char_storage = ((short)(((nk_text_undo_record *)state.UndoRec + i)->char_storage - n)); } } } --state.UndoPoint; nk_memcopy(state.UndoRec, (nk_text_undo_record *)state.UndoRec + 1, (ulong)((ulong)(state.UndoPoint) * (ulong)sizeof(nk_text_undo_record))); } }
public static void nk_textedit_undo(nk_text_edit state) { NkTextUndoState s = state.undo; nk_text_undo_record u = new nk_text_undo_record(); nk_text_undo_record *r; if ((s.UndoPoint) == (0)) { return; } u = (nk_text_undo_record)(s.UndoRec[s.UndoPoint - 1]); r = (nk_text_undo_record *)s.UndoRec + s.RedoPoint - 1; r->char_storage = (short)(-1); r->insert_length = (short)(u.delete_length); r->delete_length = (short)(u.insert_length); r->where = (int)(u.where); if ((u.delete_length) != 0) { if ((s.UndoCharPoint + u.delete_length) >= (999)) { r->insert_length = (short)(0); } else { int i; while ((s.UndoCharPoint + u.delete_length) > (s.RedoCharPoint)) { nk_textedit_discard_redo(s); if ((s.RedoPoint) == (99)) { return; } } r = (nk_text_undo_record *)s.UndoRec + s.RedoPoint - 1; r->char_storage = ((short)(s.RedoCharPoint - u.delete_length)); s.RedoCharPoint = ((short)(s.RedoCharPoint - u.delete_length)); for (i = (int)(0); (i) < (u.delete_length); ++i) { s.UndoChar[r->char_storage + i] = (char)(state._string_[(int)(u.where + i)]); } } state._string_.remove_at((int)(u.where), (int)(u.delete_length)); } if ((u.insert_length) != 0) { state._string_.insert_at((int)(u.where), (char *)s.UndoChar + u.char_storage, (int)(u.insert_length)); s.UndoCharPoint = ((short)(s.UndoCharPoint - u.insert_length)); } state.cursor = (int)((short)(u.where + u.insert_length)); s.UndoPoint--; s.RedoPoint--; }
public static void nk_textedit_redo(nk_text_edit state) { NkTextUndoState s = state.undo; nk_text_undo_record *u; nk_text_undo_record r = new nk_text_undo_record(); if ((s.RedoPoint) == (99)) { return; } u = (nk_text_undo_record *)s.UndoRec + s.UndoPoint; r = (nk_text_undo_record)(s.UndoRec[s.RedoPoint]); u->delete_length = (short)(r.insert_length); u->insert_length = (short)(r.delete_length); u->where = (int)(r.where); u->char_storage = (short)(-1); if ((r.delete_length) != 0) { if ((s.UndoCharPoint + u->insert_length) > (s.RedoCharPoint)) { u->insert_length = (short)(0); u->delete_length = (short)(0); } else { int i; u->char_storage = (short)(s.UndoCharPoint); s.UndoCharPoint = ((short)(s.UndoCharPoint + u->insert_length)); for (i = (int)(0); (i) < (u->insert_length); ++i) { s.UndoChar[u->char_storage + i] = (char)(state._string_[(int)(u->where + i)]); } } state._string_.remove_at((int)(r.where), (int)(r.delete_length)); } if ((r.insert_length) != 0) { state._string_.insert_at((int)(r.where), (char *)s.UndoChar + r.char_storage, (int)(r.insert_length)); } state.cursor = (int)(r.where + r.insert_length); s.UndoPoint++; s.RedoPoint++; }
public static nk_text_undo_record *nk_textedit_create_undo_record(NkTextUndoState state, int numchars) { nk_textedit_flush_redo(state); if ((state.UndoPoint) == (99)) { nk_textedit_discard_undo(state); } if ((numchars) > (999)) { state.UndoPoint = (short)(0); state.UndoCharPoint = (short)(0); return(null); } while ((state.UndoCharPoint + numchars) > (999)) { nk_textedit_discard_undo(state); } return((nk_text_undo_record *)state.UndoRec + (state.UndoPoint++)); }
public static char *nk_textedit_createundo(NkTextUndoState state, int pos, int insert_len, int delete_len) { nk_text_undo_record *r = nk_textedit_create_undo_record(state, (int)(insert_len)); if ((r) == (null)) { return(null); } r->where = (int)(pos); r->insert_length = ((short)(insert_len)); r->delete_length = ((short)(delete_len)); if ((insert_len) == (0)) { r->char_storage = (short)(-1); return(null); } else { r->char_storage = (short)(state.UndoCharPoint); state.UndoCharPoint = ((short)(state.UndoCharPoint + insert_len)); return((char *)state.UndoChar + r->char_storage); } }
public static void nk_textedit_flush_redo(NkTextUndoState state) { state.RedoPoint = (short)(99); state.RedoCharPoint = (short)(999); }