protected override void Start() { base.Start(); guid = Utils.IntToGuid(GetInstanceID()); if (textComponent == null) { textComponent = GetComponentInChildren <Text>(); } ; myWriteStream = new MyWriteStream(this); TextGenerator textGen = new TextGenerator(); TextGenerationSettings generationSettings = textComponent.GetGenerationSettings(textComponent.rectTransform.rect.size); var areaHeight = textComponent.rectTransform.rect.height; float textHeight = textGen.GetPreferredHeight("M", generationSettings); var maxNumberOfLines = (uint)Mathf.FloorToInt(areaHeight / textHeight); var areaWidth = textComponent.rectTransform.rect.width; float textWidth = textGen.GetPreferredWidth("M", generationSettings); var maxNumberOfColumns = (uint)Mathf.FloorToInt(areaWidth / textWidth); device = new StdLib.Ecma48.Device(maxNumberOfColumns, maxNumberOfLines); var writer = new StreamWriter(OpenWrite()); writer.AutoFlush = true; client = new StdLib.Ecma48.Client(writer); }
public override void Main(string[] arguments) { var dirPath = Environment.CurrentDirectory; if (arguments.Length > 0) { dirPath = Path.GetFullPath(arguments[0]); } var dir = Directory.GetDirEntry(dirPath); if (!dir.Exists) { throw new Error("directory '" + dir.FullName + "' doesnt exist"); } var ecma48 = new StdLib.Ecma48.Client(Console.Out); ecma48.ResetAttributes(); int counter = 0; foreach (var d in dir.EnumerateDirectories()) { counter++; ecma48.SetForegroundColor(StdLib.Ecma48.Color.Default); Console.Write(d.CreationTime + " " + d.LastWriteTime); ecma48.SetForegroundColor(StdLib.Ecma48.Color.Cyan); Console.WriteLine(" D " + d.Name); } foreach (var f in dir.EnumerateFiles()) { counter++; ecma48.SetForegroundColor(StdLib.Ecma48.Color.Default); Console.Write(f.CreationTime + " " + f.LastWriteTime); ecma48.SetForegroundColor(StdLib.Ecma48.Color.Green); Console.WriteLine(" F " + f.Name); } if (counter == 0) { Console.WriteLine("'" + dir.FullName + "' is empty"); } ecma48.ResetAttributes(); }
bool TryExecuteInbuilt(string name, params string[] arguments) { if (name == "clr" || name == "clear" || name == "cls") { var client = new StdLib.Ecma48.Client(Console.Out); client.EraseDisplay(); } else if (name == "help" || name == "man" || name == "?") { var d = Directory.GetDirEntry("/bin/"); Console.WriteLine("list of programs or command you can run:"); Console.WriteLine("\tshell commands:"); foreach (var i in new string[] { "clr", "help", "cd", "logout", "who", "instal" }) { Console.WriteLine("\t\t" + i); } Console.WriteLine("\tprograms from " + d.FullName + ":"); foreach (var f in d.EnumerateFiles()) { Console.WriteLine("\t\t" + f.Name); } } else if (name == "cd") { if (arguments.Length != 1) { throw new Error("one argument required"); } var p = arguments[0]; var d = Directory.GetDirEntry(p); if (!d.Exists) { throw new Error("directory '" + p + "' ('" + d.FullName + "') doesnt exist"); } Environment.CurrentDirectory = d.FullName; } else if (name == "logout") { TryExecuteInbuilt("clear", null); shouldContinue = false; } else if (name == "who") { //To see list of logged in user type who or w command: Console.WriteLine(this.Environment.UserName); } else if (name == "instal") { var p = "/"; if (arguments.Length == 1) { p = Path.GetFullPath(arguments[0]); } new InitializeFileSystem().Install(Session, p); } else { return(false); } return(true); }