Exemplo n.º 1
0
        // Buttons for Debug
        void Button01(object sender, EventArgs args)
        {
            prolog.Reset();

            CommandLines.Last().Command = "[test.txt].";
            CommandLines.Last().CommandLabel.Text = CommandLines.Last().Command;
            CommandLines.Last().CommandEntry.Focus();

            //Label label = new Label();

            //string code = File.ReadAllText("/Users/atsu/Projects/Xamarin/App/Prolog/Prolog/SyntaxChecker.pl");
            //string code = File.ReadAllText(WorkingDir + "test.txt");

            //label.Text = code;
            //Console.Children.Add(label);

            //if (SetClause(prolog, code))
            //    StatusLabel.Text = "Set Clauses";


            //List<Solution> solutions = GetSolutions(prolog, query);
            //label.Text += SolutionsString(solutions);

            //var solution = prolog.GetAllSolutions("test.prolog", query);
            //foreach(var s in solution.NextSolution)
            //    label.Text += s.ToString();

            //Console.Children.Add(label);

            //prolog.Reset();
            //AddPrompt(GetPromptText(prolog.Prompt));
        }
Exemplo n.º 2
0
        void Button02(object sender, EventArgs args)
        {
            //prolog.Reset();
            //Label label = new Label();
            //string code = "square(X,Y) :- Y is X * X. ";
            string query = "split(\"ab.cd.\", X).";

            //string codeTitle = "conde2";

            //label.Text =
            //    string.Format("{0} {1}\n", prolog.Prompt, query);

            //if (SetClause(prolog, code, false, codeTitle))
            //    StatusLabel.Text = "Set Clauses";

            CommandLines.Last().Command = query;
            CommandLines.Last().CommandLabel.Text = CommandLines.Last().Command;
            CommandLines.Last().CommandEntry.Focus();

            //List<Solution> solutions = GetSolutions(prolog, query);
            //label.Text += SolutionsString(solutions);
            //Console.Children.Add(label);

            //prolog.Reset();
            //AddPrompt(GetPromptText(prolog.Prompt));

            /*
             * Console.HeightRequest = Console.Height + 100.0;
             *
             * Label3.Text = string.Format("Console Size = ( {0}, {1} )",
             *                          Console.Width, Console.HeightRequest);
             * //Label2.Text = "Clicked " + Console.HeightRequest.ToString();
             * ConsoleBack.ScrollToAsync(0, Console.HeightRequest, false);
             */
        }
Exemplo n.º 3
0
        async void CancelEditor(object sender, EventArgs e)
        {
            if (FileEditor.Text != OriginalFile)
            {
                if (await DisplayAlert("Don't Save?", "", "Cancel", "OK"))
                {
                    return;
                }
            }

            FileEditorGrid.IsVisible = false;
            CommandLines.Last().CommandEntry.Focus();

            /*
             * if (FileEditor.Text == OriginalFile)
             * {
             *  FileEditorGrid.IsVisible = false;
             *  CommandLines.Last().CommandEntry.Focus();
             * }
             * else if(!await DisplayAlert("Don't Save?", "", "Cancel", "OK"))
             * {
             *  FileEditorGrid.IsVisible = false;
             *  CommandLines.Last().CommandEntry.Focus();
             * }
             */
        }
Exemplo n.º 4
0
        // Buttons of FileEditor Menu:
        //     save File & exit, save File, exit without saving file
        void SaveExitFile(object sender, EventArgs e)
        {
            // PCL Storage: Write content in IFile
            IWriteFile(CurrentFile.iFile, FileEditor.Text);

            FileEditorGrid.IsVisible = false;
            CommandLines.Last().CommandEntry.Focus();
        }
Exemplo n.º 5
0
        // Buttons of FileEditor Menu:
        //     save File & exit, save File, exit without saving file
        void SaveExitFile(object sender, EventArgs e)
        {
            string name = (FileEditorTitle.Text).Substring(11);

            File.WriteAllText(WorkingDir + name, FileEditor.Text);
            FileEditorGrid.IsVisible = false;
            CommandLines.Last().CommandEntry.Focus();
        }
Exemplo n.º 6
0
        public MainPage()
        {
            InitializeComponent();

            CreateRootFolder();

            AddPrompt(CurrentFolder.Path);

            // Just after launching the App, Entry.Focus() doesn't work like
            // ScrollToAsync() due to timing probelm(?), so maake it into Timer
            Device.StartTimer(TimeSpan.FromMilliseconds(1), () =>
            {
                CommandLines.Last().CommandEntry.Focus();
                return(false);   // Timer Cycle is only one time
            });
        }
Exemplo n.º 7
0
        public MainPage()
        {
            InitializeComponent();

            // Add the 1st Prompt on the Console
#if SystemIO
            AddPrompt(GetPromptText());
#elif PCLStorage
            CreateRootFolder();
            AddPrompt(CurrentFolder.Path);
            //Label1.Text = LocalStorage.
#endif

            // Just after launching the App, Entry.Focus() doesn't work
            // due to timing probelm(?), so maake it into Timer
            Device.StartTimer(TimeSpan.FromMilliseconds(1), () =>
            {
                CommandLines.Last().CommandEntry.Focus();
                return(false);   // Timer Cycle is only one time
            });
        }
Exemplo n.º 8
0
        // Identify Input Command and Execute it
        async void CommandExecute(string command)
        {
            string result = "";

            // Get the first three characters of command
            string com = command;

            if (command != null)
            {
                if (command.Length > 3)
                {
                    com = command.Substring(0, 3);
                }
            }


            // Identify the command from the first three characters
            switch (com)
            {
            case "":
            case null:
                AddPrompt(CurrentFolder.Path);
                return;

            case "pro":
                if (command == "prolog")
                {
                    RunProlog = true;
                    prolog.Reset();
                    result = "\n";
                }
                else
                {
                    result = "Command Invalid";
                }
                break;

            case "dir":
                result = dir();
                break;

            case "pwd":
                result = CurrentFolder.Path + "\n";
                break;

            case "mkd":
                result = await mkdir(command);

                break;

            case "cd ":
                result = await cd(command);

                break;

            case "del":
                result = await del(command);

                break;

            case "mor":
                result = await more(command);

                break;

            case "ed ":
                result = await ed(command);

                break;



            default:
                result = "No Command" + "\n";
                break;
            }

            // Display the Command Execute Result following the Command Line
            Console.Children.Add(new Label()
            {
                Text = result
            });

            // Store the result
            CommandLines.Last().Results = result;

            // Add a new Command Line
            //AddPrompt(CurrentFolder.Path);
            AddPrompt(GetPromptText());
        }
Exemplo n.º 9
0
        //string WorkingDir = @"C:\Users\0000010745011\AppData\Local\Packages\135baee3-8b33-4698-955b-a2060bcefdfe_zkjxvjmeh878e\LocalState\RootFolder";

        // Identify Input Command and Execute it
        void CommandExecute(string command)
        {
            string result = ""; // String of the command execute result

            // Get the three characters of the command to identify
            string com = command;

            if (command != null)
            {
                if (command.Length > 3)
                {
                    com = command.Substring(0, 3);
                }
            }

            // Identify the command from the extracted three characters
            switch (com)
            {
            case "":        // No command, only CR
            case null:
                AddPrompt(GetPromptText());
                return;

            case "pro":     // Run the Prolog Interpreter
                if (command == "prolog")
                {
                    RunProlog = true;
                    prolog.Reset();
                    result = "\n";
                }
                else
                {
                    result = "Command Invalid";
                }

                break;

            case "dir":     // Show the files and the directories
                result = dir();
                break;

            case "pwd":     // Print the current working directory
                result = ">" + CurrentDir + "\n";
                break;


            case "ed ":     // Run the file editor
                result = ed(command);
                break;

            default:        // Text other than the commands is entered, return the text
                result = command + "\n";
                break;
            }

            // Display the Command Execute Result following the Command Line
            Console.Children.Add(new Label()
            {
                Text = result
            });

            // Store the result
            CommandLines.Last().Results = result;

            // Add a new Command Line
            AddPrompt(GetPromptText());
        }
Exemplo n.º 10
0
 void Button02(object sender, EventArgs args)
 {
     IDleteAllObjects(LocalStorage);
     CommandLines.Last().CommandEntry.Focus();
 }
Exemplo n.º 11
0
 void CancelEditor(object sender, EventArgs e)
 {
     FileEditorGrid.IsVisible = false;
     CommandLines.Last().CommandEntry.Focus();
 }
Exemplo n.º 12
0
 // Focus Command Line, if Tap Console
 void OnTapConsole(object sender, EventArgs args)
 {
     CommandLines.Last().CommandEntry.Focus();
 }
Exemplo n.º 13
0
        async void PrologInterpreter(string command)
#endif
        {
            string          result    = "";
            string          com       = "";
            List <Solution> solutions = new List <Solution>();

            // Get the first character of the command
// #if iOS
            if (command != null)
            {
// #else // else if UWP
//             if(command != "")
// #endif
                com = command.Substring(0, 1);
            }

            // Identify the command from the three characters
            switch (com)
            {
            case "":
            case null:
                AddPrompt(GetPromptText());
                return;

            case "l":       // List Segments of the current folder
                if (command == "ls.")
                {
                    result = ls();
                    break;
                }
                else
                {
                    goto default;
                }

            case "[":       // Load Program
#if SystemIO
                result = SetProgram(command);
#elif PCLStorage
                result = await SetProgram(command);
#endif
                break;


            case "h":       // Exit Prolog Interpreter
                if (command == "halt.")
                {
                    RunProlog = false;
                    prolog.Reset();
                    result = "\n";
                    //System.Diagnostics.Process.GetCurrentProcess().CloseMainWindow();
                    break;
                }
                else
                {
                    goto default;
                }
            //{
            //    result = "Command Invalid";
            //}
            //break;

            case "r":       // Reset Prolog Engine
                if (command == "reset.")
                {
                    prolog.Reset();
                    result = "\n";
                    break;
                }
                else
                {
                    goto default;
                }
            //{
            //    result = "Command Invalid";
            //}
            //break;


            default:        // Query Input
                solutions = GetSolutions(prolog, command);
                result    = SolutionsString(solutions);
                break;
            }

            // Display the Command Execute Result following the Command Line
            Console.Children.Add(new Label()
            {
                Text = result
            });

            // Store the result
            CommandLines.Last().Results = result;

            // Add a new Command Line
            AddPrompt(GetPromptText());
        }