Example #1
0
        public void SimpleAddAndReadTest()
        {
            const int size     = 100;
            var       cl       = new CursorList <string>();
            var       saveList = new List <string>();

            foreach (var index in Enumerable.Range(0, size))
            {
                string msg = $"Index_{index}";
                cl.Add(msg);
                saveList.Add(msg);
            }

            cl.Count.Should().Be(size);
            saveList.Count.Should().Be(size);

            cl.Zip(saveList, (o, i) => new { o, i })
            .All(x => x.o == x.i)
            .Should().BeTrue();

            foreach (var index in Enumerable.Range(0, size))
            {
                cl[index].Should().Be(saveList[index]);
            }

            cl.Clear();
            cl.Count.Should().Be(0);
            cl.EndOfList.Should().BeTrue();
        }
Example #2
0
        public void UseCurorTest()
        {
            const int size = 100;
            var       cl   = new CursorList <string>();

            foreach (var index in Enumerable.Range(0, size))
            {
                string msg = $"Index_{index}";
                cl.Add(msg);
            }

            cl.Count.Should().Be(size);

            var testList = new List <string>();

            while (!cl.EndOfList)
            {
                testList.Add(cl.Next());
            }

            testList.Count.Should().Be(size);

            cl.Zip(testList, (o, i) => new { o, i })
            .All(x => x.o == x.i)
            .Should().BeTrue();
        }
Example #3
0
        private BashHandler()
        {
            Initalize();
#if DEBUG
            CursorList.ForEach(s => Console.WriteLine(s)); // Would run
#endif
        }
Example #4
0
        public void SetCursorTest()
        {
            const int size = 100;
            var       cl   = new CursorList <string>();

            foreach (var index in Enumerable.Range(0, size))
            {
                string msg = $"Index_{index}";
                cl.Add(msg);
            }

            cl.Count.Should().Be(size);

            var testList = new List <string>(Enumerable.Range(0, size).Select(x => ""));

            foreach (var index in Enumerable.Range(0, size))
            {
                testList[index] = cl.Current;
                cl.Cursor++;
            }

            bool test = false;

            try
            {
                cl.Cursor++;
                cl.Next();
                test = true;
            }
            catch (InvalidOperationException)
            {
                test = false;
            }
            test.Should().BeFalse();

            testList.Count.Should().Be(size);

            cl.Zip(testList, (o, i) => new { o, i })
            .All(x => x.o == x.i)
            .Should().BeTrue();
        }
Example #5
0
        public void CursorPushPopTest()
        {
            const int size = 100;
            var       cl   = new CursorList <string>();
            var       rnd  = new Random();

            foreach (var index in Enumerable.Range(0, size))
            {
                string msg = $"Index_{index}";
                cl.Add(msg);
            }

            cl.Count.Should().Be(size);

            int rndIndex = rnd.Next(0, size - 10);

            foreach (var index in Enumerable.Range(0, rndIndex))
            {
                cl.Next();
            }

            int    saveCursor = cl.Cursor;
            string saveValue  = cl.Current;

            cl.SaveCursor();

            foreach (var index in Enumerable.Range(0, 5))
            {
                cl.Next();
            }

            saveValue.Should().NotBe(cl.Current);
            (saveCursor + 5).Should().Be(cl.Cursor);

            cl.RestoreCursor();
            saveCursor.Should().Be(cl.Cursor);
            saveValue.Should().Be(cl.Current);
        }
Example #6
0
        private void TuioChannelHelper_OnIncomingTuioCursor(TuioCursor c, IncomingType type)
        {
            switch (type)
            {
            case IncomingType.New:
                lock (cursorSync)
                    CursorList.Add(c.SessionID, new TuioCursorContainer(c, type));
                break;

            case IncomingType.Update:
                lock (cursorSync)
                {
                    CursorList[c.SessionID].TuioCursor.update(c);
                    CursorList[c.SessionID].Type = type;
                }
                break;

            case IncomingType.Remove:
                lock (cursorSync)
                    CursorList[c.SessionID].Type = type;
                break;
            }
        }
Example #7
0
        private void Initalize()
        {
            ThemeOutput = Bash(@"
                        for f in ~/.themes/*
                        do
                            if [[ -d ""$f/gtk-3.0"" ]]
                            then
                                        echo $(basename -- ""$f"")
                            fi
                        done ") +
                          Bash(@"
                        for f in /usr/share/themes/*
                        do
                            if [[ -d ""$f/gtk-3.0"" ]]
                            then
                                        echo $(basename -- ""$f"")
                            fi
                        done");
            IconOutput = Bash(@"for f in /usr/share/icons/*
                        do
                            if [[ -f ""$f/index.theme""     ]]
                            then
                                        echo $(basename -- ""$f"")
                            fi
                        done ")
                         + Bash(@"for f in ~/.local/share/icons/*
                        do
                            if [[ -f ""$f/index.theme""  ]]
                            then
                                        echo $(basename -- ""$f"")
                            fi
                        done ")
                         + Bash(@"for f in ~/.icons/*
                        do
                            if [[ -f ""$f/index.theme""  ]]
                            then
                                        echo $(basename -- ""$f"")
                            fi
                        done ");

            CursorOutput = Bash(@"for f in /usr/share/icons/*
                        do
                            if [[ -f ""$f/index.theme""  &&    -d ""$f/cursors"" ]]
                            then
                                        echo $(basename -- ""$f"")
                            fi
                        done ")
                           + Bash(@"for f in ~/.local/share/icons/*
                       do
                            if [[ -f ""$f/index.theme""  &&    -d ""$f/cursors"" ]]
                            then
                                        echo $(basename -- ""$f"")
                            fi
                        done ")
                           + Bash(@"for f in ~/.icons/*
                       do
                            if [[ -f ""$f/index.theme""  &&    -d ""$f/cursors"" ]]
                            then
                                        echo $(basename -- ""$f"")
                            fi
                        done ");



            ShellOutput = Bash(@"
                        for f in /usr/share/themes/*
                        do
                            if [[ -d ""$f/gnome-shell"" ]]
                                    then
                                        
                                        echo $(basename -- ""$f"")
                                        fi
                                    done") + Bash(@"
                        for f in ~/.themes/*
                        do
                            if [[ -d ""$f/gnome-shell"" ]]
                                    then
                                        echo $(basename -- ""$f"")
                                        fi
                                    done");

            Box box = new Box(Orientation.Vertical, 6);

            ThemeList = ThemeOutput.Split("\n").ToList();
            ThemeList.RemoveAll(s => string.IsNullOrWhiteSpace(s));
            // ThemeList.ForEach(s=>Console.Write(s+"\n"));
            ThemeList = ThemeList.Distinct().ToList();
            ThemeList.Sort();

            IconList = IconOutput.Split("\n").ToList();
            IconList.RemoveAll(s => string.IsNullOrWhiteSpace(s));
            // IconList.ForEach(s=>Console.Write(s+"\n"));
            IconList = IconList.Distinct().ToList();
            IconList.Sort();

            ShellList = ShellOutput.Split("\n").ToList();
            ShellList.RemoveAll(s => string.IsNullOrWhiteSpace(s));
            // iconList.ForEach(s=>Console.Write(s+"\n"));
            ShellList = ShellList.Distinct().ToList();
            ShellList.Sort();

            CursorList = CursorOutput.Split("\n").ToList();
            CursorList.RemoveAll(s => string.IsNullOrWhiteSpace(s));
            CursorList = CursorList.Distinct().ToList();
            CursorList.Sort();
            UserThemeExtensionExists = CheckUserThemeExtExists();
        }
Example #8
0
 public ParserContext(IEnumerable <IToken> tokens)
 {
     tokens      = tokens ?? throw new ArgumentException(nameof(tokens));
     InputTokens = new CursorList <IToken>(tokens);
 }