private void LiveErrors_Tick(object sender, EventArgs e) { string fileName = "Untitled.lan"; if (path != null) { fileName = path.Substring(path.LastIndexOf('\\') + 1); } LangManager langManager = new LangManager(fileName); langManager.INTERPRET = false; langManager.updateCode(codeRTB.Text); langManager.lastLiveException = ""; Thread thread = new Thread(new ThreadStart(langManager.run)); thread.Start(); thread.Join(1000); ErrorsShower.Text = langManager.lastLiveException; if (langManager.lastLiveException.Length > 0) { string lineNumber = langManager.lastLiveException; int number = -1; try { lineNumber = lineNumber.Substring(5); lineNumber = lineNumber.Substring(0, lineNumber.IndexOf(':')); number = Convert.ToInt32(lineNumber); } catch (Exception) { // Nothing to do here } LineNumberer.ErrorLineNumber = number; } else { LineNumberer.ErrorLineNumber = -1; } LineNumberer.Refresh(); langManager.INTERPRET = true; }
private void codeRTB_KeyDown(object sender, KeyEventArgs e) { ButtonPressed(e); if (e.KeyCode == Keys.Tab) { codeRTB.SelectedText = " "; e.SuppressKeyPress = true; } if (e.KeyCode == Keys.Enter) { int selpos = codeRTB.SelectionStart; int lastbn = 0; string text = codeRTB.Text.Substring(0, selpos); lastbn = text.LastIndexOf('\n'); text = text.Substring(lastbn + 1); Match match = Regex.Match(text, "[ ]*"); string spaces = match.Value; codeRTB.SelectedText = "\n" + spaces; e.SuppressKeyPress = true; } if (e.KeyCode == Keys.F9) { int lnNum = getLineNumberAt(codeRTB.Text, codeRTB.SelectionStart); if (LineNumberer.BreakPoints.Contains(lnNum)) { LineNumberer.BreakPoints.Remove(lnNum); } else { LineNumberer.BreakPoints.Add(lnNum); } LineNumberer.Refresh(); } if (e.KeyCode == Keys.K && e.Modifiers == Keys.Control) { try { Parser parser = new Parser(new LangManager("")); parser.updateTokens(new Lexer(new LangManager(""), codeRTB.Text).lex()); codeRTB.SelectionStart = 0; codeRTB.SelectionLength = codeRTB.Text.Length; codeRTB.SelectedText = ((StatementList)parser.parse()).ToString(false); codeRTB.SelectionStart = 0; codeRTB.SelectionLength = 0; } catch (LangException) { // Nothing to do here /* * * ░░░░░▄▄▄▄▄▄░░░░░░░░░░ * ░░▄█▀░░░░░▄▀▄░░░░░░░░ * ░█░▀▀▀▀▀▀▀▀░░█▄░░░░░░ * █▀░░░░░░░░░░░░█░░░░░░ * █░░░░░░░░░░░░░█░░░░░░ * ▀█░░░░░░░░░░░░█░░░░░░ * ░▀▄░░░░░░░░░▄█░░░░░░░ * ░░░▀█▄▄▄▄▄▄██▄▄░░░░░░ * ░░▄▄█▀███▀██████░░░░░ * ░░▀██░░██▀█████▄▄░░░░ * ░░░░░░░░░░▄▄███▀█▄▀▄░ * ░░▄█▄▄▄██████▀▄▀▄▀█▄▀ * ░██░░░▀██▀░░░░░░▄▀▄█░ * ░█▄░░░░░█▄░░░░░░░▀░░░ * ░░▀█▄░░░░▀▀▀░░░░░░░░░ */ } } if (e.KeyCode == Keys.F && e.Modifiers == Keys.Control) { Finder.Visible = !Finder.Visible; if (Finder.Visible) { Finder.Focus(); } } }