public void Execute() { var consoleWrapper = new ConsoleWrapper(); ScoreBoard scores = new ScoreBoard(consoleWrapper); scores.Source = "../../Resources/topScores.txt"; scores.Load(); scores.Print(); }
public void FindVehicleByLicense() { if (Garage.Count() == 0) { ConsoleWrapper.WritePreLinePostLine(ResourceContext.Language.GetString("Garage_Empty")); return; } ConsoleWrapper.WritePreLine(ResourceContext.Language.GetString("Input_License_Plate_To_Search_For")); string input = InputHandler.InputLicensePlate(); ListVehicles(input); }
private void Write(Vehicle vehicle) { WriteType(vehicle.GetType()); foreach (var prop in vehicle.GetProperties()) { string resourceId = ResourceContext.PropertyToId.GetString(prop.Key); ConsoleWrapper.WriteLine("{0}: {1}", new object[] { ResourceContext.Language.GetString(resourceId), prop.Value }, new ConsoleColor[] { ConsoleColor.Yellow, ConsoleColor.Blue }); } }
public void ListVehicles() { foreach (var vehicle in Garage) { Console.WriteLine(); Write(vehicle); } Console.WriteLine(); ConsoleWrapper.WriteLine("Garaget har totalt {0} parkeringsplatser. {1} är nu upptagna!", new object[] { Garage.Capacity, Garage.Count() }, new ConsoleColor[] { ConsoleColor.Blue, ConsoleColor.Blue }); }
public string InputLicensePlate() { ConsoleWrapper.WritePreLine(ResourceContext.Language.GetString("Vehicle_License_Plate") + ":", ConsoleColor.Yellow); string input = ConsoleWrapper.ReadLine(ConsoleColor.Blue); while (String.IsNullOrWhiteSpace(input) || !ValidationHandler.Validate(input, "LicensePlate")) { ConsoleWrapper.WriteLine(ResourceContext.Language.GetString("Invalid_Input"), ConsoleColor.Red); ConsoleWrapper.Write(ResourceContext.Language.GetString("Vehicle_License_Plate") + ":", ConsoleColor.Yellow); input = ConsoleWrapper.ReadLine(ConsoleColor.Blue); } return(input); }
public void PrintMenu(bool printHeader = false) { if (printHeader && this.header != null) { WriteLine(header); } foreach (var menuItem in menuItems) { ConsoleWrapper.Write(Environment.NewLine + "{0} -> {1}", new object[] { menuItem.Command, menuItem.Description }, new ConsoleColor[] { ConsoleColor.Green, ConsoleColor.White }); } }
private int InputAttributeIndex(List <string> allAttributes) { ConsoleWrapper.WritePreLine(ResourceContext.Language.GetString("Input_Command") + ":"); int input = ConsoleWrapper.ReadLine(ConsoleColor.Green)[0] - 48; while (!(input >= 0 && input < allAttributes.Count)) { ConsoleWrapper.WritePreLinePostLine(ResourceContext.Language.GetString("Invalid_Option"), ConsoleColor.Red); ConsoleWrapper.WritePreLine(ResourceContext.Language.GetString("Input_Command") + ":"); input = ConsoleWrapper.ReadLine(ConsoleColor.Green)[0] - 48; } return(input); }
public static void Main(string[] args) { var consoleWrapper = new ConsoleWrapper(); var outputHandler = new OutputHandler(consoleWrapper); var inputHandler = new InputHandler(outputHandler, consoleWrapper); var gameRunner = new GameRunner(outputHandler); var coordinator = new GameCoordinator(gameRunner, inputHandler); outputHandler.Welcome(); coordinator.Play(); }
public ConsoleWrapper GetOrCreate(int id, string command) { lock (this.terminalLock) { if (this.terminals.TryGetValue(id, out ConsoleWrapper con)) { return(con); } con = new ConsoleWrapper(command); this.terminals[id] = con; return(con); } }
static IServiceProvider ConfigureServices(IConfiguration configuration, bool database) { var services = new ServiceCollection(); services.AddLogging(logger => { logger.ClearProviders(); logger.AddConsole(); }); // Configure database if (database) { // Create ConsoleWrapper for separation of concern var consoleWrapper = new ConsoleWrapper(); var databaseFlag = configuration.GetValue <DatabaseFlag>("database"); services.AddDbContext <PhotoContext>(options => { string connectionString = DatabaseUtil.ConstructDbConnectionString(configuration, databaseFlag, consoleWrapper); switch (databaseFlag) { case DatabaseFlag.SQLServer: options.UseSqlServer(connectionString); break; case DatabaseFlag.MySQL: options.UseMySQL(connectionString); break; case DatabaseFlag.PostgreSQL: options.UseNpgsql(connectionString); break; case DatabaseFlag.SQLite: default: options.UseSqlite(connectionString); break; } }); } // Setup DI for services services.AddSingleton(configuration) .AddSingleton <IRenameService, RenameService>() .AddSingleton <ISortService, SortService>() .AddSingleton <IOrganizerService, OrganizerService>(); return(services.BuildServiceProvider()); }
// --- Main --------------------------------------------------------------------------------------------------------- static void Main() { try { ExecuteBot(); } catch (Exception ex) { try { Config.Save(); } catch (Exception e) { Console.WriteLine("Config Save Error: " + e); } ConsoleWrapper.WriteLine("Error Message: " + ex.Message + "\nStack Trace: " + ex.StackTrace); Saver.SaveToLog("Error Message: " + ex.Message + "\nStack Trace: " + ex.StackTrace); Environment.Exit(1); } }
private void OnLoaded(object sender, RoutedEventArgs e) { if (!this.IsOSVersionSupported()) { var msg = System.Text.Encoding.UTF8.GetBytes( "\x1b[2J\x1b[H" + "ConPTY APIs required for this application are not available.\r\n" + $"Please update to Windows 10 1809 (build {MinimumWindowsVersion}) or higher.\r\n" + "Press any key to exit.\r\n"); this.screen.Buffer.Append(msg, msg.Length); this.KeyDown += (_, args) => this.Close(); return; } this.InitializeWindowSizeHandling(); this.HandleConfigurationChanged(null, null); this.console = TerminalManager.Instance.GetOrCreate(0, "wsl.exe"); this.keyHandler = new KeyHandler(this.console); this.keyHandler.KeyboardShortcut += this.HandleKeyboardShortcut; this.screen.Buffer = this.console.Buffer; this.console.Buffer.PropertyChanged += (_, args) => { if (args.PropertyName == "Title") { this.Dispatcher.InvokeAsync(() => this.Title = this.console.Buffer.Title); } }; this.KeyDown += this.keyHandler.OnKeyDown; this.KeyDown += (_, args) => this.screen.VerticalOffset = double.MaxValue; // force scroll on keypress. this.TextInput += this.keyHandler.OnTextInput; // XXX: a very hacky paste! this.MouseRightButtonDown += (_, args) => { var text = Clipboard.GetData(DataFormats.Text) as string; if (!string.IsNullOrWhiteSpace(text)) { this.console.SendText(System.Text.Encoding.UTF8.GetBytes(text)); } }; this.console.PropertyChanged += this.HandleConsoleClosed; this.Closing += this.HandleClosing; }
/// <summary> /// R_RenderView /// r_refdef must be set before the first call /// </summary> public void RenderView( ) { if (Host.Cvars.NoRefresh.Get <Boolean>()) { return; } if (_WorldEntity.model == null || Host.Client.cl.worldmodel == null) { Utilities.Error("R_RenderView: NULL worldmodel"); } Double time1 = 0; if (Host.Cvars.Speeds.Get <Boolean>( )) { Host.Video.Device.Finish( ); time1 = Timer.GetFloatTime( ); _BrushPolys = 0; _AliasPolys = 0; } //_IsMirror = false; if (Host.Cvars.glFinish.Get <Boolean>()) { Host.Video.Device.Finish( ); } Clear( ); // render normal view RenderScene( ); DrawViewModel( ); DrawWaterSurfaces( ); // render mirror view //Mirror(); PolyBlend( ); if (Host.Cvars.Speeds.Get <Boolean>()) { var time2 = Timer.GetFloatTime( ); ConsoleWrapper.Print("{0,3} ms {1,4} wpoly {2,4} epoly\n", ( Int32 )((time2 - time1) * 1000), _BrushPolys, _AliasPolys); } }
// Events private static async Task Client_JoinedGuild(SocketGuild arg) { try { bool hasWrite = false, hasRead = false, hasReadHistory = false, hasFiles = false; SocketGuild g = Program.GetGuildFromID(479950092938248193); IUser u = g.Users.FirstOrDefault(x => x.Id == Program.GetSelf().Id); if (u != null) { IEnumerable <IRole> roles = (u as IGuildUser).RoleIds.Select(x => (u as IGuildUser).Guild.GetRole(x)); foreach (IRole r in roles) { if (r.Permissions.SendMessages) { hasWrite = true; } if (r.Permissions.ViewChannel) { hasRead = true; } if (r.Permissions.ReadMessageHistory) { hasReadHistory = true; } if (r.Permissions.AttachFiles) { hasFiles = true; } } } if (!hasWrite) { IDMChannel c = g.Owner.CreateDMChannelAsync().Result; await c.SendMessageAsync("How can one be on your server and not have the right to write messages!? This is outrageous, its unfair!"); return; } if (!hasRead || !hasReadHistory || !hasFiles) { await g.TextChannels.ElementAt(0).SendMessageAsync("Whoever added me didn't give me all the usual permissions :c"); return; } } catch (Exception e) { ConsoleWrapper.WriteLine(e.ToString(), ConsoleColor.Red); } }
// Cbuf_AddText() // as new commands are generated from the console or keybindings, // the text is added to the end of the command buffer. public void Append(string text) { if (string.IsNullOrEmpty(text)) { return; } if (this.Buffer.Length + text.Length > this.Buffer.Capacity) { ConsoleWrapper.Print("Cbuf.AddText: overflow!\n"); } else { this.Buffer.Append(text); } }
public static void Main() { var repository = new UserRepository(); var broker = new MessageBroker(repository); var commandFactory = new CommandFactory(broker); var parser = new InputParser(commandFactory); var formaterFactory = new MessageFormaterFactory(); var consoleWrapper = new ConsoleWrapper(); var program = new Program(consoleWrapper, parser, formaterFactory); while (program.ProcessUserInput()) { } }
private VehicleType InputVehicleEnum() { ConsoleWrapper.WritePreLine(ResourceContext.Language.GetString("Input_Command") + ":"); int input = ConsoleWrapper.ReadLine(ConsoleColor.Green)[0] - 48; while (!Enum.IsDefined(typeof(VehicleType), input)) { ConsoleWrapper.WritePreLinePostLine(ResourceContext.Language.GetString("Invalid_Option"), ConsoleColor.Red); ConsoleWrapper.WritePreLine(ResourceContext.Language.GetString("Input_Command") + ":"); input = ConsoleWrapper.ReadLine(ConsoleColor.Green)[0] - 48; } return((VehicleType)input); }
static void Main() { var path = @"C:\Work1"; var destFiletxt = Path.Combine(path, "newTest.txt"); var fileInfo = new FileInfoWrapper(path); var console = new ConsoleWrapper(); var file = new FileWrapper(); var directory = new DirectoryWrapper(); var abstractHandler = new TxtHandler(file, fileInfo, console, directory); abstractHandler.Create(path); abstractHandler.Change(destFiletxt, "33"); abstractHandler.Open(destFiletxt); var destFileNametxt = Path.Combine(path, @"Test.txt"); abstractHandler.Save(destFiletxt, destFileNametxt); Directory.Delete(path, true); var pathjson = @"C:\Work3"; var destFilejson = Path.Combine(pathjson, "tsconfig1.json"); var fileInfojson = new FileInfoWrapper(pathjson); var jsonHandler = new UserHandler(file, fileInfojson, console, directory); jsonHandler.Create(pathjson); var user1 = new User(); user1.Company = "Google"; user1.Name = "Bob Gates"; user1.Age = 51; var json = JsonConvert.SerializeObject(user1, Newtonsoft.Json.Formatting.Indented); var pathJson = @"jsconfig1.json"; jsonHandler.Change(pathJson, json); jsonHandler.Open(destFilejson); var destFileNamejson = Path.Combine(pathjson, @"Json.json"); jsonHandler.Save(pathJson, destFileNamejson); //Directory.Delete(pathjson, true); Console.ReadKey(); }
/// <summary> /// Creates the ninject kernel instance, initializes it and starts a new instance of <see cref="KinokoApplication"/>. /// </summary> public void Start() { try { CreateOptions(); CreateAndConfigureNinjectKernel(); RunApplication(); } catch (Exception ex) { IConsole console = new ConsoleWrapper(); UI guiHelpers = new UI(console); guiHelpers.DisplayError(ex); guiHelpers.Pause(); } }
public void ListByVehicleType() { if (Garage.Occupied == 0) { ConsoleWrapper.WritePreLinePostLine(ResourceContext.Language.GetString("Garage_Empty")); return; } var viechleTypes = Garage.GroupByType(); foreach (var viechleType in viechleTypes) { Console.WriteLine(); WriteType(viechleType.Key); Console.WriteLine(ResourceContext.Language.GetString("Vehicle_Count") + ": " + viechleType.Count()); } }
private void ListVehicles(String licensePlate) { Vehicle vehicle = Garage.Find(licensePlate); if (vehicle != null) { Console.WriteLine(); Write(vehicle); } else { Console.WriteLine(); ConsoleWrapper.WriteLine("{0}: {1}", new object[] { ResourceContext.Language.GetString("Search_Failed"), licensePlate }, new ConsoleColor[] { ConsoleColor.White, ConsoleColor.Blue }); } }
public void OnConnected() { ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; List <string> PatchNotes = new List <string>(); HtmlWeb web = new HtmlWeb(); var searchDoc = web.Load("https://github.com/niklasCarstensen/Discord-Bot/commits/master"); var commits = searchDoc.DocumentNode.SelectNodes("//a[contains(@class, 'Link--primary text-bold js-navigation-open markdown-title')]"); foreach (var commit in commits) { if (commit.InnerText == Config.Data.LastCommitMessage) { break; } PatchNotes.Add($"[{commit.InnerText}](https://github.com{commit.GetAttributeValue("href", "")})"); } if (commits.Count > 0) { Config.Data.LastCommitMessage = commits.First().InnerText; } Config.Save(); PatchNotes.Reverse(); if (PatchNotes.Count > 0) { #if !DEBUG EmbedBuilder Embed = new EmbedBuilder { Title = "Patch Notes:" }; Embed.WithThumbnailUrl("https://community.canvaslms.com/community/image/2043/2.png?a=1646"); Embed.WithDescription(PatchNotes.Aggregate((x, y) => x + "\n" + y)); foreach (ulong id in Config.Data.PatchNoteSubscribedChannels) { DiscordNETWrapper.SendEmbed(Embed, (ISocketMessageChannel)Program.GetChannelFromID(id)).Wait(); } #else ConsoleWrapper.WriteLine("Patch Notes:" + PatchNotes.Aggregate((x, y) => x + "\n" + y), ConsoleColor.Cyan); #endif } }
void InitConsolesList() { if (changesMade) { // (any non-null value will work -- the display is controlled by FootnoteTemplate in the xaml...) this.Footnote = true; return; } var defaultConsole = this.consoleManager.GetDefaultConsole(); string defaultConsoleAlias = defaultConsole == null ? null : defaultConsole.Alias; string selectedConsoleAlias = null; ConsoleWrapper selectedConsole = null; if (this.listview != null) { var selected = this.listview.SelectedItem as ConsoleWrapper; if (selected != null) { selectedConsoleAlias = selected.Alias; } } this.Consoles.Clear(); this.consoleInEditMode = null; var consoles = this.consoleManager.GetConsoles(); ConsoleIdentifier.UpdateOutstandingIdentifiers(defaultConsole, consoles); foreach (var c in consoles) { var newWrapper = new ConsoleWrapper(c, c.Alias == defaultConsoleAlias); this.Consoles.Add(newWrapper); if (c.Alias == selectedConsoleAlias) { selectedConsole = newWrapper; } } if (selectedConsole != null) { this.listview.SelectedItem = selectedConsole; } }
public void Setup() { _boardInitializerDouble = A.Fake <BoardInitializer>(); _consoleWrapperDouble = A.Fake <ConsoleWrapper>(); _boardPrinterDouble = A.Fake <BoardPrinter>(); _consoleCoordinateReaderDouble = A.Fake <ConsoleCoordinatesReader>(); _inputMapperDouble = A.Fake <CoordinatesMapper>(); _shotResultMapperDouble = A.Fake <ShotResultMapper>(); _subject = new ConsoleGame( _boardInitializerDouble, _consoleWrapperDouble, _boardPrinterDouble, _consoleCoordinateReaderDouble, _inputMapperDouble, _shotResultMapperDouble); }
public void DoWork() { int initialNumber, finalNumber; var totalOfLetters = 0; initialNumber = UserInterface.GetValue("Insira o número inicial:"); finalNumber = UserInterface.GetValue("Insira o número final:"); var rangeNumbers = Enumerable.Range(initialNumber, finalNumber - initialNumber + 1); foreach (var number in rangeNumbers) { totalOfLetters += NumberConverter.GetWord(number).Length; } ConsoleWrapper.WriteLine($"Total de caracteres: {totalOfLetters}"); ConsoleWrapper.ReadLine(); }
public static void ShowActiveAsserts() { ConsoleWrapper.HLine(); ConsoleWrapper.WriteLine("ASSERT SWITCHES:"); foreach (Switch s in _switches.Values) //Switches.Values) { ConsoleWrapper.Write("[ "); ConsoleWrapper.Write(s.On ? "ON " : "OFF", s.On? ConsoleColor.Green : ConsoleColor.Red); ConsoleWrapper.Write(" ] "); ConsoleWrapper.WriteLine(s.Name); foreach (string line in s.Description) { ConsoleWrapper.WriteLine(" " + line, ConsoleColor.Gray); } } ConsoleWrapper.HLine(); }
// COM_Path_f public static void Path_f(CommandMessage msg) { ConsoleWrapper.Print("Current search path:\n"); foreach (var sp in _SearchPaths) { if (sp.pack != null) { ConsoleWrapper.Print("{0} ({1} files)\n", sp.pack.filename, sp.pack.files.Length); } if (sp.pk3 != null) { ConsoleWrapper.Print("{0} ({1} files)\n", sp.pk3filename, sp.pk3.Entries.Count); } else { ConsoleWrapper.Print("{0}\n", sp.filename); } } }
/// <summary> /// R_SetupAliasFrame /// </summary> protected virtual void SetupAliasFrame(Single shadeLight, Int32 frame, Double time, aliashdr_t paliashdr, Single[] shadeDots) { if ((frame >= paliashdr.numframes) || (frame < 0)) { ConsoleWrapper.Print("R_AliasSetupFrame: no such frame {0}\n", frame); frame = 0; } var pose = paliashdr.frames[frame].firstpose; var numposes = paliashdr.frames[frame].numposes; if (numposes > 1) { var interval = paliashdr.frames[frame].interval; pose += ( Int32 )(time / interval) % numposes; } DrawAliasFrame(shadeLight, shadeDots, paliashdr, pose); }
private void ListHelp() { Console.WriteLine(); ConsoleWrapper.WriteLine("{0} - {1}", new object[] { ResourceContext.Language.GetString("Help_Green"), ResourceContext.Language.GetString("Help_Green_Description") }, new ConsoleColor[] { ConsoleColor.Green, ConsoleColor.White }); ConsoleWrapper.WriteLine("{0} - {1}", new object[] { ResourceContext.Language.GetString("Help_Blue"), ResourceContext.Language.GetString("Help_Blue_Description") }, new ConsoleColor[] { ConsoleColor.Blue, ConsoleColor.White }); ConsoleWrapper.WriteLine("{0} - {1}", new object[] { ResourceContext.Language.GetString("Help_Yellow"), ResourceContext.Language.GetString("Help_Yellow_Description") }, new ConsoleColor[] { ConsoleColor.Yellow, ConsoleColor.White }); ConsoleWrapper.WriteLine("{0} - {1}", new object[] { ResourceContext.Language.GetString("Help_Red"), ResourceContext.Language.GetString("Help_Red_Description") }, new ConsoleColor[] { ConsoleColor.Red, ConsoleColor.White }); }
/// <summary> /// R_SetupAliasFrame /// </summary> protected virtual void SetupAliasFrame(float shadeLight, int frame, double time, aliashdr_t paliashdr, float[] shadeDots) { if (frame >= paliashdr.numframes || frame < 0) { ConsoleWrapper.Print("R_AliasSetupFrame: no such frame {0}\n", frame); frame = 0; } var pose = paliashdr.frames[frame].firstpose; var numposes = paliashdr.frames[frame].numposes; if (numposes > 1) { var interval = paliashdr.frames[frame].interval; pose += ( int )(time / interval) % numposes; } this.DrawAliasFrame(shadeLight, shadeDots, paliashdr, pose); }
static void StartTwitterLoop() { long lastMentionId = twitterService.ListTweetsMentioningMe(new ListTweetsMentioningMeOptions() { Count = 1 }).Last().Id; TweetSharpWrapper.PrintTwitterRateLimitStatus(twitterService); while (true) { var mentions = twitterService.ListTweetsMentioningMe(new ListTweetsMentioningMeOptions() { SinceId = lastMentionId }); if (mentions != null) { foreach (var m in mentions.Reverse()) { ConsoleWrapper.WriteLine($"{DateTime.Now.ToLongTimeString()} Recieved Tweet: " + m.Text); try { TwitterChannel c = new TwitterChannel(m, twitterService); TweetSharpWrapper.PrintTwitterRateLimitStatus(twitterService); if (c.InitialMessage.Content.StartsWith(Program.Prefix)) { Task.Run(() => Program.ParallelMessageReceived(c.InitialMessage)); } } catch (Exception e) { ConsoleWrapper.WriteLine("Error handling Tweet: " + e); } lastMentionId = m.Id; } } Thread.Sleep(45000); // 48 seconds times 75 hourly allowed hits would exactly be one hour } }
void OnAddClicked(object sender, RoutedEventArgs e) { var newWrapper = new ConsoleWrapper(null, false); this.Consoles.Add(newWrapper); this.listview.SelectedItem = newWrapper; SetConsoleInEditMode(newWrapper, false); SetButtonStates(); }
void SetConsoleInEditMode(ConsoleWrapper console, bool revertChanges) { if (this.consoleInEditMode != null) { this.consoleInEditMode.InEditMode = false; if (revertChanges) { this.consoleInEditMode.Alias = oldEditedConsoleAlias; this.consoleInEditMode.Address = oldEditedConsoleAddress; } else { this.consoleInEditMode.IsNew = false; } } this.consoleInEditMode = console; if (this.consoleInEditMode != null) { this.changesMade = true; console.InEditMode = true; this.oldEditedConsoleAlias = console.Alias; this.oldEditedConsoleAddress = console.Address; EventHandler handler = null; handler = (s, e) => { if (this.listview.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated) { var container = this.listview.ItemContainerGenerator.ContainerFromItem(this.consoleInEditMode); if (container != null) { this.listview.ItemContainerGenerator.StatusChanged -= handler; var textBoxes = container.FindVisualChildren<TextBox>(); bool focused = false; foreach (var textBox in textBoxes) { if (!focused) { focused = textBox.Focus(); } textBox.SelectAll(); } } } }; this.listview.ItemContainerGenerator.StatusChanged += handler; handler(null, EventArgs.Empty); } SetButtonStates(); }
public LineEditMode() { this.DefaultSrcPath = "lem_default.nana"; this.Lines = new List<string>(); this.CW = new ConsoleWrapper(); this.CW.OnRead = OnRead; Cmds = new Commands(this); this.EditPrompt = delegate() { return string.Format("{0:D" + Lines.Count.ToString().Length + "}>", Row); //return this.Row.ToString() + ">"; }; this.CmdPrompt = delegate() { return ":"; }; // OnReads Dictionary<ConsoleKey, Action<ConsoleWrapper, ConsoleKeyInfo, Box<bool>>> d; d = new Dictionary<ConsoleKey, Action<ConsoleWrapper, ConsoleKeyInfo, Box<bool>>>(); this.OnReads = d; d.Add(ConsoleKey.Enter /**/, delegate(ConsoleWrapper c, ConsoleKeyInfo inf, Box<bool> quit) { if (IsEdit) EditEnter(c, inf, quit); else CmdEnter(c, inf, quit); }); d.Add(ConsoleKey.Escape /**/, delegate(ConsoleWrapper c, ConsoleKeyInfo inf, Box<bool> quit) { c.N().Home(); if (IsEdit) SetCmdMode(); else SetEditMode(); }); d.Add(ConsoleKey.Backspace /**/, delegate(ConsoleWrapper c, ConsoleKeyInfo inf, Box<bool> quit) { LE.Bs(); }); d.Add(ConsoleKey.Tab /**/, delegate(ConsoleWrapper c, ConsoleKeyInfo inf, Box<bool> quit) { LE.Tab(); }); d.Add(ConsoleKey.LeftArrow /**/, delegate(ConsoleWrapper c, ConsoleKeyInfo inf, Box<bool> quit) { LE.L(); }); d.Add(ConsoleKey.RightArrow /**/, delegate(ConsoleWrapper c, ConsoleKeyInfo inf, Box<bool> quit) { LE.R(); }); d.Add(ConsoleKey.UpArrow /**/, delegate(ConsoleWrapper c, ConsoleKeyInfo inf, Box<bool> quit) { }); d.Add(ConsoleKey.DownArrow /**/, delegate(ConsoleWrapper c, ConsoleKeyInfo inf, Box<bool> quit) { }); d = new Dictionary<ConsoleKey, Action<ConsoleWrapper, ConsoleKeyInfo, Box<bool>>>(); this.OnReadsAlt = d; d.Add(ConsoleKey.G /**/, delegate(ConsoleWrapper c, ConsoleKeyInfo inf, Box<bool> quit) { SimCmd("go"); }); d.Add(ConsoleKey.L /**/, delegate(ConsoleWrapper c, ConsoleKeyInfo inf, Box<bool> quit) { SimCmd("list"); }); d.Add(ConsoleKey.P /**/, delegate(ConsoleWrapper c, ConsoleKeyInfo inf, Box<bool> quit) { SimCmd("parse"); }); }
public void CmdEnter(ConsoleWrapper c, ConsoleKeyInfo inf, Box<bool> quit) { CW.N(); string ln = LE.Line; try { string[] args; args = Regex.Split(ln.Trim(), @"\s+"); if (args.Length == 0) args = new string[] { "" }; Cmds.Execute(args, quit); if (quit.Value == false) SetEditMode(); } catch (Exception e) { if (e.InnerException != null) e = e.InnerException; if (e is Error) { Error er_ = e as Error; string s = FormatError(er_); c.WN(s); } else { c.WN(e.ToString()); } LE.Init(); LE.Ins(ln); } }
public void OnRead(ConsoleWrapper c, ConsoleKeyInfo inf, Box<bool> quit) { if (inf.Modifiers == ConsoleModifiers.Alt && OnReadsAlt.ContainsKey(inf.Key)) { OnReadsAlt[inf.Key](c, inf, quit); return; } if (OnReads.ContainsKey(inf.Key)) { OnReads[inf.Key](c, inf, quit); } else { LE.Ins(inf.KeyChar.ToString()); } }
public void EditEnter(ConsoleWrapper c, ConsoleKeyInfo inf, Box<bool> quit) { CW.N(); if (Row > Lines.Count) { Lines.Add(LE.Line); } else { Lines.Insert(Row - 1, LE.Line); } Row += 1; LE.Init(); }