public static void nk_textedit_discard_redo(nk_text_undo_state state)
        {
            ulong num;
            int   k = (int)(99 - 1);

            if (state.redo_point <= k)
            {
                if ((state.undo_rec[k].char_storage) >= (0))
                {
                    int n = (int)(state.undo_rec[k].insert_length);
                    int i;
                    state.redo_char_point = ((short)(state.redo_char_point + n));
                    num = ((ulong)(999 - state.redo_char_point));
                    nk_memcopy((char *)state.undo_char + state.redo_char_point, (char *)state.undo_char + state.redo_char_point - n,
                               (ulong)(num * sizeof(char)));
                    for (i = (int)(state.redo_point); (i) < (k); ++i)
                    {
                        if ((((nk_text_undo_record *)state.undo_rec + i)->char_storage) >= (0))
                        {
                            ((nk_text_undo_record *)state.undo_rec + i)->char_storage =
                                ((short)(((nk_text_undo_record *)state.undo_rec + i)->char_storage + n));
                        }
                    }
                }
                ++state.redo_point;
                num = ((ulong)(99 - state.redo_point));
                if ((num) != 0)
                {
                    nk_memcopy((nk_text_undo_record *)state.undo_rec + state.redo_point - 1,
                               (nk_text_undo_record *)state.undo_rec + state.redo_point, (ulong)(num * (ulong)sizeof(nk_text_undo_record)));
                }
            }
        }
示例#2
0
        public static int?nk_textedit_createundo(nk_text_undo_state state, int pos, int insert_len, int delete_len)
        {
            int?rpos = nk_textedit_create_undo_record(state, (int)(insert_len));

            if (rpos == null)
            {
                return(null);
            }

            var rposv = rpos.Value;

            state.undo_rec[rposv].where         = (int)(pos);
            state.undo_rec[rposv].insert_length = ((short)(insert_len));
            state.undo_rec[rposv].delete_length = ((short)(delete_len));
            if ((insert_len) == (0))
            {
                state.undo_rec[rposv].char_storage = (short)(-1);
                return(null);
            }
            else
            {
                state.undo_rec[rposv].char_storage = (short)(state.undo_char_point);
                state.undo_char_point = ((short)(state.undo_char_point + insert_len));
                return(state.undo_rec[rposv].char_storage);
            }
        }
 public static void nk_textedit_discard_undo(nk_text_undo_state state)
 {
     if ((state.undo_point) > (0))
     {
         if ((state.undo_rec[0].char_storage) >= (0))
         {
             int n = (int)(state.undo_rec[0].insert_length);
             int i;
             state.undo_char_point = ((short)(state.undo_char_point - n));
             nk_memcopy(state.undo_char, (char *)(char *)state.undo_char + n,
                        (ulong)((ulong)(state.undo_char_point) * sizeof(uint)));
             for (i = (int)(0); (i) < (state.undo_point); ++i)
             {
                 if ((((nk_text_undo_record *)state.undo_rec + i)->char_storage) >= (0))
                 {
                     ((nk_text_undo_record *)state.undo_rec + i)->char_storage =
                         ((short)(((nk_text_undo_record *)state.undo_rec + i)->char_storage - n));
                 }
             }
         }
         --state.undo_point;
         nk_memcopy(state.undo_rec, (nk_text_undo_record *)state.undo_rec + 1,
                    (ulong)((ulong)(state.undo_point) * (ulong)sizeof(nk_text_undo_record)));
     }
 }
示例#4
0
        public static void nk_textedit_discard_redo(nk_text_undo_state state)
        {
            int num;
            int k = (int)(99 - 1);

            if (state.redo_point <= k)
            {
                if ((state.undo_rec[k].char_storage) >= (0))
                {
                    int n = (int)(state.undo_rec[k].insert_length);
                    int i;
                    state.redo_char_point = ((short)(state.redo_char_point + n));
                    num = 999 - state.redo_char_point;

                    Array.Copy(state.undo_char, state.redo_char_point - n, state.undo_char, state.redo_char_point, num);
                    for (i = (int)(state.redo_point); (i) < (k); ++i)
                    {
                        if ((state.undo_rec[i].char_storage) >= (0))
                        {
                            state.undo_rec[i].char_storage =
                                ((short)(state.undo_rec[i].char_storage + n));
                        }
                    }
                }
                ++state.redo_point;
                num = 99 - state.redo_point;
                if ((num) != 0)
                {
                    Array.Copy(state.undo_rec, state.redo_point, state.undo_rec, state.redo_point - 1, num);
                }
            }
        }
示例#5
0
        public static void nk_textedit_discard_undo(nk_text_undo_state state)
        {
            if ((state.undo_point) > (0))
            {
                if ((state.undo_rec[0].char_storage) >= (0))
                {
                    int n = (int)(state.undo_rec[0].insert_length);
                    int i;
                    state.undo_char_point = ((short)(state.undo_char_point - n));

                    Array.Copy(state.undo_char, n, state.undo_char, 0, state.undo_char_point);
                    for (i = (int)(0); (i) < (state.undo_point); ++i)
                    {
                        if ((state.undo_rec[i].char_storage) >= (0))
                        {
                            state.undo_rec[i].char_storage =
                                ((short)(state.undo_rec[i].char_storage - n));
                        }
                    }
                }
                --state.undo_point;

                Array.Copy(state.undo_rec, 1, state.undo_rec, 0, state.undo_point);
            }
        }
示例#6
0
        public static void nk_textedit_undo(nk_text_edit state)
        {
            nk_text_undo_state  s = state.Undo;
            nk_text_undo_record u = new nk_text_undo_record();

            if ((s.undo_point) == (0))
            {
                return;
            }
            u = (nk_text_undo_record)(s.undo_rec[s.undo_point - 1]);
            fixed(nk_text_undo_record *r2 = s.undo_rec)
            {
                var r = r2 + s.redo_point - 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.undo_char_point + u.delete_length) >= (999))
                    {
                        r->insert_length = (short)(0);
                    }
                    else
                    {
                        int i;
                        while ((s.undo_char_point + u.delete_length) > (s.redo_char_point))
                        {
                            nk_textedit_discard_redo(s);
                            if ((s.redo_point) == (99))
                            {
                                return;
                            }
                        }
                        r = r2 + s.redo_point - 1;
                        r->char_storage   = ((short)(s.redo_char_point - u.delete_length));
                        s.redo_char_point = ((short)(s.redo_char_point - u.delete_length));
                        for (i = (int)(0); (i) < (u.delete_length); ++i)
                        {
                            s.undo_char[r->char_storage + i] = (char)(state.Text[(int)(u.where + i)]);
                        }
                    }
                    state.Text.remove_at((int)(u.where), (int)(u.delete_length));
                }
            }

            if ((u.insert_length) != 0)
            {
                state.Text.insert_at((int)(u.where), s.undo_char, u.char_storage, (int)(u.insert_length));
                s.undo_char_point = ((short)(s.undo_char_point - u.insert_length));
            }

            state.Cursor = (int)((short)(u.where + u.insert_length));
            s.undo_point--;
            s.redo_point--;
        }
示例#7
0
        public static void nk_textedit_redo(nk_text_edit state)
        {
            nk_text_undo_state   s = state.Undo;
            nk_text_undo_record *u;
            nk_text_undo_record  r = new nk_text_undo_record();

            if ((s.redo_point) == (99))
            {
                return;

                fixed(nk_text_undo_record *u2 = s.undo_rec)
                {
                    u = u2 + s.undo_point;
                    r = (nk_text_undo_record)(s.undo_rec[s.redo_point]);
                    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.undo_char_point + u->insert_length) > (s.redo_char_point))
                        {
                            u->insert_length = (short)(0);
                            u->delete_length = (short)(0);
                        }
                        else
                        {
                            int i;
                            u->char_storage   = (short)(s.undo_char_point);
                            s.undo_char_point = ((short)(s.undo_char_point + u->insert_length));
                            for (i = (int)(0); (i) < (u->insert_length); ++i)
                            {
                                s.undo_char[u->char_storage + i] = (char)(state.Text[(int)(u->where + i)]);
                            }
                        }
                        state.Text.remove_at((int)(r.where), (int)(r.delete_length));
                    }
                }

                if ((r.insert_length) != 0)
                {
                    state.Text.insert_at((int)(r.where), s.undo_char, r.char_storage, (int)(r.insert_length));
                }

                state.Cursor = (int)(r.where + r.insert_length);
                s.undo_point++;
                s.redo_point++;
        }
        public static nk_text_undo_record *nk_textedit_create_undo_record(nk_text_undo_state state, int numchars)
        {
            nk_textedit_flush_redo(state);
            if ((state.undo_point) == (99))
            {
                nk_textedit_discard_undo(state);
            }
            if ((numchars) > (999))
            {
                state.undo_point      = (short)(0);
                state.undo_char_point = (short)(0);
                return(null);
            }

            while ((state.undo_char_point + numchars) > (999))
            {
                nk_textedit_discard_undo(state);
            }
            return((nk_text_undo_record *)state.undo_rec + (state.undo_point++));
        }
        public static char *nk_textedit_createundo(nk_text_undo_state 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.undo_char_point);
                state.undo_char_point = ((short)(state.undo_char_point + insert_len));
                return((char *)state.undo_char + r->char_storage);
            }
        }
 public static void nk_textedit_flush_redo(nk_text_undo_state state)
 {
     state.redo_point      = (short)(99);
     state.redo_char_point = (short)(999);
 }