Ejemplo n.º 1
0
 public CodeFile(SubDirectory directory, string fileName)
 {
     this.FileName = fileName;
     this.Location = directory;
     string[] split = fileName.Split('.');
     this.FileType = split [split.Length - 1];
     code          = System.IO.File.ReadAllText(directory.Location + "/" + fileName);
 }
Ejemplo n.º 2
0
        /*
         * Controls;
         *  Exit: CTRL+C
         *  Save: CTRL+O (O for out)
         *  Exit and Save (CTRL+X)
         */

        public Bolt(string[] args)
        {
            string fileLocation = args[0];

            if (!fileLocation.Contains("/"))
            {
                fileLocation = Directory.GetCurrentDirectory() + "/" + fileLocation;
            }
            //Load parameters from command line arguments
            LoadParams(args);

            if (!DO_EXECUTE)
            {
                return;
            }

            if (!File.Exists(fileLocation))
            {
                File.Create(fileLocation).Close();
            }

            //Uncomment for file input information, aswell as; working directory.
            ///Console.WriteLine("DIR: " + Directory.GetCurrentDirectory());
            ///Console.WriteLine(fileLocation);
            ///return;

            instance = this;

            //TODO: check for NO_LOAD_CONFIG flag in command line args
            settings = new Settings();
            settings.LoadSettings(((OSInfo.OS_OSX || OSInfo.OS_WINDOWS) ? "/Users" : "/home") + $"/{Environment.UserName}/.boltrc");
            if (Settings.LOAD_FAILED)
            {
                Logger.LogError("Failed to load settings... Exiting.");
                return;
            }

            Console.Clear();

            GUI.Initialize(this);

            isRepository = Directory.Exists(fileLocation) && File.Exists(fileLocation);

            if (isRepository)
            {
                //Editing a directory (Repository)
                RootDirectory = new SubDirectory(fileLocation);
                RootDirectory.ScanDirectory();
            }
            else
            {
                //Editing a single file
                codeFile = new CodeFile(new SubDirectory(fileLocation), Path.GetFileName(fileLocation));
            }

            inputManager = new InputManager(this);

            //Console Initialization
            //Undone when CTRL+C is pressed in InputManager.cs
            Console.CursorVisible        = true;
            Console.TreatControlCAsInput = true;

            //Initialize Text Ballet (Bottom of screen)
            commandPanel = new CommandPanel(this);
            commandPanel.Format(new Location(0, GUI.ScreenHeight), new Size(GUI.ScreenWidth, 1));
            AddComponent(commandPanel);

            //Initialize Text/Code Editor
            editor = new Editor(this, codeFile);
            editor.Format(new Location(0, 0), new Size(GUI.ScreenWidth, GUI.ScreenHeight - 1));
            editor.Focus();
            AddComponent(editor);

            //Start the GUI Listener
            //this will raise an event when the console is resized.
            GUI.StartGUIEventListener();

            //Draw components to screen
            Refresh();

            inputManager.StartListener();
        }