Ejemplo n.º 1
0
            public Edit(string s)
            {
                int    i     = 0;
                bool   exits = false;
                string ss    = "";

                name        = s;
                list1.x     = 0;
                list1.w     = 78;
                list1.y     = 0;
                list1.h     = 20;
                list1.start = 0;
                list1.clear();
                if (name == "")
                {
                    list1.add("", list1.length + 1);
                }
                if (name == "")
                {
                    name = "new.lst";
                }
                try{
                    list1.load(name);
                }catch {
                    list1.add("", list1.length + 1);
                }


                pos = 0;
                int chrs = 0;

                while (!exits)
                {
                    lineInsert inputs = new lineInsert();
                    Console.Clear();
                    list1.report();
                    ss = list1.gets(pos);
                    Console.CursorLeft = list1.y;
                    Console.CursorTop  = pos - list1.start;
                    chrs         = 0;
                    inputs.value = ss;
                    returner rr = inputs.input(ss, chrs);
                    ss   = rr.rets;
                    chrs = rr.keys;
                    if (pos >= list1.length)
                    {
                        list1.add(ss, pos);
                    }
                    else
                    {
                        list1.change(ss, pos);
                    }

                    if (chrs == 8)
                    {
                        exits = true;
                    }

                    if (chrs == 1)
                    {
                        pos = pos + 1;
                        list1.add("", pos);
                    }
                    if (chrs == 2)
                    {
                        pos = pos - 1;
                    }
                    if (chrs == 3)
                    {
                        pos = pos + 1;
                        if (pos > list1.length)
                        {
                            list1.add("", pos);
                        }
                    }
                    if (chrs == 4)
                    {
                        list1.start = list1.start - 19;
                        pos         = pos - 19;
                    }
                    if (chrs == 5)
                    {
                        list1.start = list1.start + 19;
                        pos         = pos + 19;
                    }
                    if (pos < 0)
                    {
                        pos         = 0;
                        list1.start = 0;
                    }
                    if (pos > list1.length)
                    {
                        pos = list1.length;
                        list1.add("", pos);
                    }
                    if (list1.start > list1.length)
                    {
                        list1.start = list1.length - 1;
                    }
                    if (list1.start < 0)
                    {
                        list1.start = 0;
                    }
                    if (list1.start < pos - 19)
                    {
                        list1.start = pos - 19;
                    }
                    if (list1.start > list1.length)
                    {
                        list1.start = list1.length - 1;
                    }
                    if (list1.start > pos)
                    {
                        list1.start = pos;
                    }
                    if (list1.start < 0)
                    {
                        list1.start = 0;
                    }
                }
                try{
                    list1.save(name);
                }catch {
                }
            }
Ejemplo n.º 2
0
            public returner input(string back, int keys)
            {
                returner       rr    = new returner();
                ConsoleKeyInfo key   = new ConsoleKeyInfo();
                string         s     = "";
                char           last  = ' ';
                char           c32   = ' ';
                char           c13   = '\r';
                int            b     = 32;
                int            bb    = 32;
                bool           exits = false;
                int            i     = 0;

                line   = 0;
                x      = Console.CursorLeft;
                y      = Console.CursorTop;
                value  = value.Replace("_", "");
                cursor = value.Length;
                cursorinsert();
                while (!exits)
                {
                    try{
                        key = Console.ReadKey(true);
                        b   = Convert.ToInt16(key.Key);
                    }catch {
                        b = 0;
                    }

                    if (key.Key == ConsoleKey.UpArrow)
                    {
                        clears();
                        tkeys = 2;
                        exits = true;
                    }
                    if (key.Key == ConsoleKey.DownArrow)
                    {
                        clears();
                        tkeys = 3;
                        exits = true;
                    }

                    if (key.Key == ConsoleKey.PageDown)
                    {
                        clears();
                        tkeys = 5;
                        exits = true;
                    }
                    if (key.Key == ConsoleKey.PageUp)
                    {
                        clears();
                        tkeys = 4;
                        exits = true;
                    }

                    if (key.Key == ConsoleKey.Escape)
                    {
                        clears();
                        tkeys = 8;
                        exits = true;
                    }



                    if (key.Key == ConsoleKey.LeftArrow)
                    {
                        value = value.Replace("_", "");
                        cursor--;
                        cursorinsert();
                        bb = 0;
                        b  = 1;
                    }
                    if (key.Key == ConsoleKey.RightArrow)
                    {
                        value = value.Replace("_", "");
                        cursor++;
                        cursorinsert();
                        bb = 0;
                        b  = 1;
                    }


                    if (key.Key == ConsoleKey.End)
                    {
                        value  = value.Replace("_", "");
                        cursor = value.Length;
                        cursorinsert();
                        bb = 0;
                        b  = 1;
                    }
                    if (key.Key == ConsoleKey.Home)
                    {
                        value  = value.Replace("_", "");
                        cursor = 0;
                        cursorinsert();
                        bb = 0;
                        b  = 1;
                    }

                    if (key.Key == ConsoleKey.Enter)
                    {
                        clears();
                        tkeys = 1;
                        exits = true;
                    }
                    if ((key.Key == ConsoleKey.Delete || key.Key == ConsoleKey.Backspace) && length > 0)
                    {
                        s = "";

                        value = value.Replace("_", "");
                        cursor--;

                        if (cursor > -1)
                        {
                            char c = value[cursor];
                            value = value.Insert(cursor, "_");
                            value = value.Replace("_" + c, "");
                        }
                        value = value.Replace("_", "");
                        cursorinsert();
                        bb = 0;
                        b  = 1;
                    }

                    if (key.KeyChar >= ' ' && length < max)
                    {
                        if (key.KeyChar != '_')
                        {
                            value = value.Replace("_", key.KeyChar.ToString());
                        }
                        value = value.Replace("_", "");
                        cursor++;
                        cursorinsert();
                    }
                }
                //value=value.Replace("_","");
                //cursorinsert();
                value   = value.Replace("_", "");
                length  = value.Length;
                rr.rets = value;
                rr.keys = tkeys;
                return(rr);
            }