コード例 #1
0
ファイル: SyntaxHighlighter.cs プロジェクト: ndrake/blink1
 private void PHPAutoIndentNeeded(object sender, AutoIndentEventArgs args)
 {
     /*
     FastColoredTextBox tb = sender as FastColoredTextBox;
     tb.CalcAutoIndentShiftByCodeFolding(sender, args);*/
     //block {}
     if (Regex.IsMatch(args.LineText, @"^[^string.Empty']*\{.*\}[^string.Empty']*$"))
         return;
     //start of block {}
     if (Regex.IsMatch(args.LineText, @"^[^string.Empty']*\{"))
     {
         args.ShiftNextLines = args.TabLength;
         return;
     }
     //end of block {}
     if (Regex.IsMatch(args.LineText, @"}[^string.Empty']*$"))
     {
         args.Shift = -args.TabLength;
         args.ShiftNextLines = -args.TabLength;
         return;
     }
     //is unclosed operator in previous line ?
     if (Regex.IsMatch(args.PrevLineText, @"^\s*(if|for|foreach|while|[\}\s]*else)\b[^{]*$"))
         if (!Regex.IsMatch(args.PrevLineText, @"(;\s*$)|(;\s*//)"))//operator is unclosed
         {
             args.Shift = args.TabLength;
             return;
         } 
 }
コード例 #2
0
ファイル: Sandbox.cs プロジェクト: 0xack13/FastColoredTextBox
 private void fctb_AutoIndentNeeded(object sender, AutoIndentEventArgs e)
 {
     if (Regex.IsMatch(e.PrevLineText, @"^\s*For\(.*\)"))
     {
         e.Shift = e.Shift + e.TabLength;
         e.ShiftNextLines = e.ShiftNextLines + e.TabLength;
         return;
     }
     if (Regex.IsMatch(e.PrevLineText, @"^\s*If\(.*\)"))
     {
         e.Shift = e.Shift + e.TabLength;
         e.ShiftNextLines = e.ShiftNextLines + e.TabLength;
         return;
     }
     if (Regex.IsMatch(e.LineText, @"###"))
     {
         e.Shift = e.Shift - e.TabLength;
         e.ShiftNextLines = e.ShiftNextLines - e.TabLength;
         return;
     }
     if (Regex.IsMatch(e.LineText, @"\$\$\$"))
     {
         e.Shift = e.Shift - e.TabLength;
         e.ShiftNextLines = e.ShiftNextLines - e.TabLength;
         return;
     }
 }
コード例 #3
0
 void fctb_AutoIndentNeeded(object sender, AutoIndentEventArgs e)
 {
     // if current line is "begin" then next
     // line shift to right
     if (e.LineText.Trim() == "begin")
     {
         e.ShiftNextLines = e.TabLength;
         return;
     }
     // if current line is "end" then current
     // and next line shift to left
     if (e.LineText.Trim() == "end")
     {
         e.Shift = -e.TabLength;
         e.ShiftNextLines = -e.TabLength;
         return;
     }
     // if previous line contains "then" or "else",
     // and current line do not contain "begin"
     // then shift current line to right
     if (Regex.IsMatch(e.PrevLineText, @"\b(then|else)\b") &&
         !Regex.IsMatch(e.LineText, @"\bbegin\b"))
     {
         e.Shift = e.TabLength;
         return;
     }
 }
コード例 #4
0
ファイル: SyntaxHighlighter.cs プロジェクト: ndrake/blink1
 public virtual void AutoIndentNeeded(object sender, AutoIndentEventArgs args)
 {
     FastColoredTextBox tb = (sender as FastColoredTextBox);
     Language language = tb.Language;
     switch (language)
     {
         case Language.CSharp: CSharpAutoIndentNeeded(sender, args); break;
         case Language.VB: VBAutoIndentNeeded(sender, args); break;
         case Language.HTML: HTMLAutoIndentNeeded(sender, args); break;
         case Language.SQL: SQLAutoIndentNeeded(sender, args); break;
         case Language.PHP: PHPAutoIndentNeeded(sender, args); break;
         default:
             break;
     }
 }
コード例 #5
0
        public virtual void AutoIndentNeeded(object sender, AutoIndentEventArgs args)
        {
            var tb = (sender as FastColoredTextBox);
            switch (tb.Language)

            {
                case "CSharp":
                    CSharpAutoIndentNeeded(sender, args);
                    break;

                case "VB":
                    VBAutoIndentNeeded(sender, args);
                    break;

                case "HTML":
                    HTMLAutoIndentNeeded(sender, args);
                    break;

                case "Xml":
                    HTMLAutoIndentNeeded(sender, args);
                    break;

                case "SQL":
                    SQLAutoIndentNeeded(sender, args);
                    break;

                case "PHP":
                    PHPAutoIndentNeeded(sender, args);
                    break;

                case "Python":
                    PythonAutoIndentNeeded(sender, args);
                    break;
                case "Ruby":
                    RubyAutoIndentNeeded(sender, args);
                    break;
                case "Lua":
                    LuaAutoIndentNeeded(sender, args);
                    break;
                default:
                    CSharpAutoIndentNeeded(sender, args);
                    break;
            }
        }
コード例 #6
0
        public override void AutoIndentNeeded(object sender, AutoIndentEventArgs args)
        {
            //end of block
            if (Regex.IsMatch(args.LineText, @"^\s*(End|EndIf|Next|Loop)\b", RegexOptions.IgnoreCase))
            {
                args.Shift          = -args.TabLength;
                args.ShiftNextLines = -args.TabLength;
                return;
            }
            //start of declaration
            if (Regex.IsMatch(args.LineText,
                              @"\b(Class|Property|Enum|Structure|Sub|Function|Namespace|Interface|Get)\b|(Set\s*\()",
                              RegexOptions.IgnoreCase))
            {
                args.ShiftNextLines = args.TabLength;
                return;
            }
            // then ...
            if (Regex.IsMatch(args.LineText, @"\b(Then)\s*\S+", RegexOptions.IgnoreCase))
            {
                return;
            }
            //start of operator block
            if (Regex.IsMatch(args.LineText, @"^\s*(If|While|For|Do|Try|With|Using|Select)\b", RegexOptions.IgnoreCase))
            {
                args.ShiftNextLines = args.TabLength;
                return;
            }

            //Statements else, elseif, case etc
            if (Regex.IsMatch(args.LineText, @"^\s*(Else|ElseIf|Case|Catch|Finally)\b", RegexOptions.IgnoreCase))
            {
                args.Shift = -args.TabLength;
                return;
            }

            //Char _
            if (args.PrevLineText.TrimEnd().EndsWith("_"))
            {
                args.Shift = args.TabLength;
                return;
            }
        }
コード例 #7
0
ファイル: FileManager.cs プロジェクト: remco138/amanda
        private void _AutoIndentNeeded(object sender, AutoIndentEventArgs e)
        {
            Match isOtherwiseRegex = Regex.Match(e.LineText.Trim(), ",* otherwise");
            int   currentIndent    = e.LineText.TakeWhile(q => q == ' ').Count(); //shouldn't be too inefficient
            int   at = e.LineText.IndexOf('=');

            AmandaTagParser tagParser = new AmandaTagParser();

            tagParser.Parse(textBox.Text);

            /*
             *              All these todo's might not be neccessary, it's pretty good right now
             */
            //If the line contains a where, we want the next lines to be indented by a tab
            if (Regex.IsMatch(e.LineText, "where"))
            {
                e.ShiftNextLines = e.TabLength;
            }

            //if the line is a condition, we want to find the '=' and indent to there, that's how youre supposed to do conditions in amanda
            else if (Regex.IsMatch(e.LineText.Trim(), ",* if"))
            {
                e.ShiftNextLines = at - currentIndent;
            }

            //If line is empty | prev line is empty | contains otherwise (which indicates the end of an if/else statement)
            else if (e.LineText.Trim() == "" || e.PrevLineText.Trim().Count() == 0 || Regex.IsMatch(e.LineText.Trim(), ",* otherwise") == true)
            {
                //Get the tag based on our current line, if we are at line 3, and there is a big function going from line 1-5, it will return that.
                AmandaTag tag = tagParser.GetTag(e.iLine);
                if (tag != null)
                {
                    e.ShiftNextLines = tag.BeginLocation.X - at;
                }

                //No function found? No problem, resort to a tab
                else
                {
                    e.ShiftNextLines = -e.TabLength;
                }
            }
        }
コード例 #8
0
 public override void AutoIndentNeeded(object sender, AutoIndentEventArgs args)
 {
     //block macro
     if (Regex.IsMatch(args.LineText, @"^\.macro\s.*\.endm$"))
     {
         return;
     }
     //start of block macro
     if (Regex.IsMatch(args.LineText, @"\.macro\b"))
     {
         args.AbsoluteIndentation = 0;
         args.ShiftNextLines      = args.TabLength;
         return;
     }
     //end of block macro
     if (Regex.IsMatch(args.LineText, @"\.endm(?:acro)?\b"))
     {
         args.AbsoluteIndentation = 0;
         args.ShiftNextLines      = args.TabLength;
         return;
     }
     //Method start
     if (Regex.IsMatch(args.LineText, @"^\s*[A-Z]\w+:"))
     {
         args.AbsoluteIndentation = 0;
         args.ShiftNextLines      = 2 * args.TabLength;
         return;
     }
     //Method end
     if (Regex.IsMatch(args.LineText, @"^\s*reti?"))
     {
         args.AbsoluteIndentation = 0;
         args.ShiftNextLines      = 2 * args.TabLength;
         return;
     }
     if (Regex.IsMatch(args.LineText, @"^\s*[a-z]\w+:"))
     {
         args.Shift          = -args.TabLength;
         args.ShiftNextLines = args.TabLength;
         return;
     }
 }
コード例 #9
0
 private void fctb_AutoIndentNeeded(object sender, AutoIndentEventArgs args)
 {
     //block {}
     if (Regex.IsMatch(args.LineText, @"^[^""']*\{.*\}[^""']*$"))
     {
         return;
     }
     //start of block {}
     if (Regex.IsMatch(args.LineText, @"^[^""']*\{"))
     {
         args.ShiftNextLines = args.TabLength;
         return;
     }
     //end of block {}
     if (Regex.IsMatch(args.LineText, @"}[^""']*$"))
     {
         args.Shift          = -args.TabLength;
         args.ShiftNextLines = -args.TabLength;
         return;
     }
     //label
     if (Regex.IsMatch(args.LineText, @"^\s*\w+\s*:\s*($|//)") &&
         !Regex.IsMatch(args.LineText, @"^\s*default\s*:"))
     {
         args.Shift = -args.TabLength;
         return;
     }
     //some statements: case, default
     if (Regex.IsMatch(args.LineText, @"^\s*(case|default)\b.*:\s*($|//)"))
     {
         args.Shift = -args.TabLength / 2;
         return;
     }
     //is unclosed operator in previous line ?
     if (Regex.IsMatch(args.PrevLineText, @"^\s*(if|for|foreach|while|[\}\s]*else)\b[^{]*$"))
     {
         if (!Regex.IsMatch(args.PrevLineText, @"(;\s*$)|(;\s*//)")) //operator is unclosed
         {
             args.Shift = args.TabLength;
         }
     }
 }
コード例 #10
0
 private void CSharpAutoIndentNeeded(object sender, AutoIndentEventArgs args)
 {
     //block {}
     if (Regex.IsMatch(args.LineText, @"^[^""']*\{.*\}[^""']*$"))
         return;
     //start of block {}
     if (Regex.IsMatch(args.LineText, @"^[^""']*\{"))
     {
         args.ShiftNextLines = args.TabLength;
         return;
     }
     //end of block {}
     if (Regex.IsMatch(args.LineText, @"}[^""']*$"))
     {
         args.Shift = -args.TabLength;
         args.ShiftNextLines = -args.TabLength;
         return;
     }
     //label
     if (Regex.IsMatch(args.LineText, @"^\s*\w+\s*:\s*($|//)") &&
         !Regex.IsMatch(args.LineText, @"^\s*default\s*:"))
     {
         args.Shift = -args.TabLength;
         return;
     }
     //some statements: case, default
     if (Regex.IsMatch(args.LineText, @"^\s*(case|default)\b.*:\s*($|//)"))
     {
         args.Shift = -args.TabLength/2;
         return;
     }
     //is unclosed operator in previous line ?
     if (Regex.IsMatch(args.PrevLineText, @"^\s*(if|for|foreach|while|[\}\s]*else)\b[^{]*$"))
         if (!Regex.IsMatch(args.PrevLineText, @"(;\s*$)|(;\s*//)")) //operator is unclosed
         {
             args.Shift = args.TabLength;
         }
 }
コード例 #11
0
ファイル: SyntaxHighlighter.cs プロジェクト: windygu/DSharp
        public virtual void AutoIndentNeeded(object sender, AutoIndentEventArgs args)
        {
            FastColoredTextBox tb       = (sender as FastColoredTextBox);
            Language           language = tb.Language;

            switch (language)
            {
            case Language.CSharp: CSharpAutoIndentNeeded(sender, args); break;

            case Language.VB: VBAutoIndentNeeded(sender, args); break;

            case Language.HTML: HTMLAutoIndentNeeded(sender, args); break;

            case Language.SQL: SQLAutoIndentNeeded(sender, args); break;

            case Language.PHP: PHPAutoIndentNeeded(sender, args); break;

            case Language.JS: CSharpAutoIndentNeeded(sender, args); break;    //JS like C#

            default:
                break;
            }
        }
コード例 #12
0
 private void PythonAutoIndentNeeded(object sender, AutoIndentEventArgs e)
 {
     if (Regex.IsMatch(e.LineText, @"^[^""']*\:"))
     {
         e.ShiftNextLines = e.TabLength;
     }
 }
コード例 #13
0
 private void fastRichTextBoxLog_AutoIndentNeeded(object sender, AutoIndentEventArgs args)
 {
     AuntoIndent(args);
 }
コード例 #14
0
 private void fctb_AutoIndentNeeded(object sender, AutoIndentEventArgs args)
 {
     Highlighter.AutoIndent(sender, args);
 }
コード例 #15
0
 private void ScpAutoIndentNeeded(object sender, AutoIndentEventArgs args)
 {
     if (!Regex.IsMatch(args.LineText, @"^\s*((?i)[i,ı]f).*((?i)end[i,ı]f)\b[^{]*$"))
     {
         if (Regex.IsMatch(args.LineText, @"^\s*((?i)[i,ı]f)"))
         {
             args.ShiftNextLines = args.TabLength;
         }
         else if (Regex.IsMatch(args.LineText, @"((?i)end[i,ı]f)\b[^{]*$"))
         {
             args.Shift = -args.TabLength;
             args.ShiftNextLines = -args.TabLength;
         }
         else if (Regex.IsMatch(args.PrevLineText, @"^\s*((?i)else[i,ı]f|(?i)el[i,ı]f|[\}\s]*(?i)else)\b[^{]*$") && !Regex.IsMatch(args.PrevLineText, @"(;\s*$)|(;\s*//)"))
         {
             args.Shift = args.TabLength;
         }
         else if (!Regex.IsMatch(args.LineText, @"^\s*((?i)for).*((?i)endfor)\b[^{]*$"))
         {
             if (Regex.IsMatch(args.LineText, @"^\s*((?i)for)"))
             {
                 args.ShiftNextLines = args.TabLength;
             }
             else if (Regex.IsMatch(args.LineText, @"((?i)endfor)\b[^{]*$"))
             {
                 args.Shift = -args.TabLength;
                 args.ShiftNextLines = -args.TabLength;
             }
             else if (!Regex.IsMatch(args.LineText, @"^\s*((?i)dorand).*((?i)enddo)\b[^{]*$"))
             {
                 if (Regex.IsMatch(args.LineText, @"^\s*((?i)dorand)"))
                 {
                     args.ShiftNextLines = args.TabLength;
                 }
                 else if (Regex.IsMatch(args.LineText, @"((?i)enddo)\b[^{]*$"))
                 {
                     args.Shift = -args.TabLength;
                     args.ShiftNextLines = -args.TabLength;
                 }
                 else if (!Regex.IsMatch(args.LineText, @"^\s*((?i)begin).*((?i)end)\b[^{]*$"))
                 {
                     if (Regex.IsMatch(args.LineText, @"^\s*((?i)begin)"))
                     {
                         args.ShiftNextLines = args.TabLength;
                     }
                     else if (Regex.IsMatch(args.LineText, @"((?i)end)\b[^{]*$"))
                     {
                         args.Shift = -args.TabLength;
                         args.ShiftNextLines = -args.TabLength;
                     }
                 }
             }
         }
     }
 }
コード例 #16
0
 public virtual void AutoIndentNeeded(object sender, AutoIndentEventArgs args)
 {
     args.TabLength = 0;
 }
コード例 #17
0
 public virtual void AutoIndentNeeded(object sender, AutoIndentEventArgs args)
 {
     var tb = (sender as FastColoredTextBox);
     Language language = tb.Language;
     switch (language)
     {
         case Language.CrocScript:
             CSharpAutoIndentNeeded(sender, args);
             break;
         case Language.PASM:
             PASMAutoIndentNeeded(sender, args);
             break;
         case Language.PHP:
             PHPAutoIndentNeeded(sender, args);
             break;
         case Language.JS:
             CSharpAutoIndentNeeded(sender, args);
             break;
         case Language.Lua:
             LuaAutoIndentNeeded(sender, args);
             break;
     }
 }
コード例 #18
0
 private void fctb_AutoIndentNeeded(object sender, AutoIndentEventArgs e)
 {
     //we assign this handler to disable AutoIndent by folding
 }
コード例 #19
0
ファイル: CODES.cs プロジェクト: avijit1258/UVA-Arena
 private void fctb1_AutoIndentNeeded(object sender, AutoIndentEventArgs e)
 {
     //auto index <-- also enables format option
     if (codeTextBox.Language == Language.Custom)
     {
         //currently indent indifferently for all languages
         // <-- need some extra work for individuals
         HighlightSyntax.AutoIndent(sender, e);
     }
 }
コード例 #20
0
        // < By WendyH ------------------------------------------
        private void PascalAutoIndentNeeded(AutoIndentEventArgs args)
        {
            Match m;
            string beginBlock = "\\b(Begin|Try|Repeat|Case)\\b";
            string endBlock   = "\\b(End|Until)\\b";
            if (Regex.IsMatch(args.LineText, @"^\s*(Begin)\b", RegexOptions.IgnoreCase)) {
                if (!Regex.IsMatch(args.PrevLineText, @"\b(Then|Do)[\s#]*$", RegexOptions.IgnoreCase)) {
                    args.AbsoluteIndentation = 0;
                    args.ShiftNextLines = args.TabLength;
                    return;
                }
            }
            m = Regex.Match(args.PrevLineText, @"^\s*(Function|Procedure)[^\(]+\(\s*([^\)]+)$", RegexOptions.IgnoreCase);
            if (m.Success) {
                args.Shift = m.Groups[2].Index;
                args.ShiftNextLines = m.Groups[2].Index;
                return;
            }
            if (Regex.IsMatch(args.LineText, @"^\s*(Var)[\s#]*$", RegexOptions.IgnoreCase)) {
                args.ShiftNextLines = args.TabLength;
                return;
            }
            if (Regex.IsMatch(args.LineText, @"^\s*(Program|Function|Procedure)\b", RegexOptions.IgnoreCase)) {
                args.AbsoluteIndentation = 0;
                //args.Shift = args.TabLength;
                return;
            }
            if (Regex.IsMatch(args.LineText, @"^\s*(Var)\s*\w", RegexOptions.IgnoreCase)) {
                if (Regex.IsMatch(args.PrevLineText, @"(^\s*(Program|Function|Procedure)\b|\)([\s;#]*|\s*:\s*\w+\s*;[\s#]*)$)", RegexOptions.IgnoreCase)) {
                    args.Shift = args.TabLength;
                    args.ShiftNextLines = args.TabLength;
                    return;
                }
            }
            int opened = DetectStartOrEndBlock(args.LineText, beginBlock, endBlock); // By WendyH
            //end of block
            //            if (Regex.IsMatch(args.LineText, @"^\s*(End|EndIf|Next|Loop)\b", RegexOptions.IgnoreCase)) {
            if (opened < 0) {
                args.Shift = -args.TabLength;
                args.ShiftNextLines = -args.TabLength;
                return;
            }
            //start of declaration
            //if (Regex.IsMatch(args.LineText, @"\b(Begin)\b", RegexOptions.IgnoreCase)) {
            if (opened > 0) {
                args.ShiftNextLines = args.TabLength;
                return;
            }
            // end block in begining and start block in end (if opened == 0)
            if (Regex.IsMatch(args.LineText, "^\\s+" + endBlock.Replace("End|", "End|Finally|"), RegexOptions.IgnoreCase)) {
                args.Shift = -args.TabLength;
                return;
            }
            // then ...
            if (Regex.IsMatch(args.LineText, @"\b(Then)\s*\S+", RegexOptions.IgnoreCase)) {
                return;
            }
            ////start of operator block
            //if (Regex.IsMatch(args.LineText, @"^\s*(If|While|For|Do|Try|With|Using|Select)\b", RegexOptions.IgnoreCase)) {
            //    args.ShiftNextLines = args.TabLength;
            //    return;
            //}
            ////Statements else, elseif, case etc
            //if (Regex.IsMatch(args.LineText, @"^\s*(Else|ElseIf|Else If|Case|Catch|Finally)\b", RegexOptions.IgnoreCase)) {
            //    args.AbsoluteIndentation = 0;
            //    args.Shift = -args.TabLength;
            //    return;
            //}
            if (Regex.IsMatch(args.PrevLineText, @"\b(AND|OR|NOT)[\s#]*$", RegexOptions.IgnoreCase)) {
                args.Shift = args.TabLength;
                return;
            }
            if (Regex.IsMatch(args.PrevLineText, @"\b(Then|Else|Do)[\s#]*$", RegexOptions.IgnoreCase)) {
                args.Shift = args.TabLength;
                return;
            }
            // Indent with '+' in the end of line --- By WendyH
            m = Regex.Match(args.PrevLineText, @"=.*?\+[\s#]*$");
            if (m.Success) {
                args.Shift = m.Index + 2 - args.AbsoluteIndentation;
                return;
            }
            m = Regex.Match(args.PrevLineText, @"\S.*?\+[\s#]*$");
            if (m.Success) {
                args.Shift = m.Index - args.AbsoluteIndentation;
                return;
            }
            // -------------------------------------------------

            //Char _
            if (args.PrevLineText.TrimEnd().EndsWith("_")) {
                args.Shift = args.TabLength;
            }
        }
コード例 #21
0
 private void EditBox_AutoIndentNeeded(object sender, AutoIndentEventArgs e)
 {
     e.ShiftNextLines = 0;
 }
コード例 #22
0
 private void CSharpAutoIndentNeeded(AutoIndentEventArgs args)
 {
     int opened = DetectStartOrEndBlock(args.LineText, "{", "}");
     //block {}
     //if (Regex.IsMatch(args.LineText, @"^[^""']*\{.*\}[^""']*$"))
     //    return;
     //start of block {}
     //if (Regex.IsMatch(args.LineText, @"^[^""']*\{")) {
     if (opened > 0) {
         args.ShiftNextLines = args.TabLength;
         return;
     }
     //end of block {}
     //if (Regex.IsMatch(args.LineText, @"}[^""']*$")) {
     if (opened < 0) {
         args.Shift = -args.TabLength;
         args.ShiftNextLines = -args.TabLength;
         return;
     }
     if (Regex.IsMatch(args.LineText, @"^\s+}")) {
         args.Shift = -args.TabLength;
         return;
     }
     // Indent with '+' in the end of line --- By WendyH
     Match m = Regex.Match(args.PrevLineText, @"=.*?\+\s*?$");
     if (m.Success) {
         args.Shift = m.Index + 2 - args.AbsoluteIndentation;
         return;
     }
     m = Regex.Match(args.PrevLineText, @"\S.*?\+\s*?$");
     if (m.Success) {
         args.Shift = m.Index - args.AbsoluteIndentation;
         return;
     }
     // -------------------------------------------------
     //label
     if (Regex.IsMatch(args.LineText, @"^\s*\w+\s*:\s*($|//)") && !Regex.IsMatch(args.LineText, @"^\s*default\s*:")) {
         args.Shift = -args.TabLength;
         return;
     }
     //some statements: case, default
     if (Regex.IsMatch(args.LineText, @"^\s*(case|default)\b.*:[\s#]*($|//)")) {
         args.Shift = -args.TabLength/2;
         return;
     }
     //is unclosed operator in previous line ?
     if (Regex.IsMatch(args.PrevLineText, @"^\s*(if|for|foreach|while|[\}\s]*else)\b[^{]*$"))
         if (!Regex.IsMatch(args.PrevLineText, @"(;\s*$)|(;[\s#]*//)")) //operator is unclosed
         {
             args.Shift = args.TabLength;
         }
 }
コード例 #23
0
 protected void CSharpAutoIndentNeeded(object sender, AutoIndentEventArgs args)
 {
     var flag = Regex.IsMatch(args.LineText, "^[^\"']*\\{.*\\}[^\"']*$");
     if (!flag)
     {
         var flag2 = Regex.IsMatch(args.LineText, "^[^\"']*\\{");
         if (flag2)
         {
             args.ShiftNextLines = args.TabLength;
         }
         else
         {
             var flag3 = Regex.IsMatch(args.LineText, "}[^\"']*$");
             if (flag3)
             {
                 args.Shift = -args.TabLength;
                 args.ShiftNextLines = -args.TabLength;
             }
             else
             {
                 var flag4 = Regex.IsMatch(args.LineText, "^\\s*\\w+\\s*:\\s*($|//)") &&
                             !Regex.IsMatch(args.LineText, "^\\s*default\\s*:");
                 if (flag4)
                 {
                     args.Shift = -args.TabLength;
                 }
                 else
                 {
                     var flag5 = Regex.IsMatch(args.LineText, "^\\s*(case|default)\\b.*:\\s*($|//)");
                     if (flag5)
                     {
                         args.Shift = -args.TabLength/2;
                     }
                     else
                     {
                         var flag6 = Regex.IsMatch(args.PrevLineText,
                             "^\\s*(if|for|foreach|while|[\\}\\s]*else)\\b[^{]*$");
                         if (flag6)
                         {
                             var flag7 = !Regex.IsMatch(args.PrevLineText, "(;\\s*$)|(;\\s*//)");
                             if (flag7)
                             {
                                 args.Shift = args.TabLength;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #24
0
 private void ProgramTextBox_AutoIndentNeeded(object sender, AutoIndentEventArgs e)
 {
     //if (e.LineText.Contains("Then")) {
     //    e.ShiftNextLines += e.TabLength;
     //}
 }
コード例 #25
0
 private void SQLAutoIndentNeeded(object sender, AutoIndentEventArgs args)
 {
     var tb = sender as FastColoredTextBox;
     tb.CalcAutoIndentShiftByCodeFolding(sender, args);
 }
コード例 #26
0
ファイル: SyntaxHighlighter.cs プロジェクト: WendyH/HMSEditor
 public void AutoIndentNeeded(object sender, AutoIndentEventArgs args)
 {
     var tb = (sender as FastColoredTextBox);
     Language language = tb.Language;
     switch (language) {
         case Language.CSharp:
             CSharpAutoIndentNeeded(sender, args);
             break;
         case Language.VB:
             VBAutoIndentNeeded(sender, args);
             break;
         case Language.HTML:
             HTMLAutoIndentNeeded(sender, args);
             break;
         case Language.XML:
             XMLAutoIndentNeeded(sender, args);
             break;
         case Language.SQL:
             SQLAutoIndentNeeded(sender, args);
             break;
         case Language.PHP:
             PHPAutoIndentNeeded(sender, args);
             break;
         case Language.JS:
             CSharpAutoIndentNeeded(sender, args);
             break; //JS like C#
         case Language.Lua:
             LuaAutoIndentNeeded(sender, args);
             break;
         // By WendyH < -------------------------------------------------------
         case Language.CPPScript:
             CSharpAutoIndentNeeded(sender, args);
             break;
         case Language.PascalScript:
             PascalAutoIndentNeeded(sender, args);
             break;
         case Language.BasicScript:
             VBAutoIndentNeeded(sender, args);
             break;
         case Language.JScript:
             CSharpAutoIndentNeeded(sender, args);
             break;
         case Language.YAML:
             CSharpAutoIndentNeeded(sender, args);
             break;
         // By WendyH > -------------------------------------------------------
         default:
             break;
     }
 }
コード例 #27
0
ファイル: SyntaxHighlighter.cs プロジェクト: zuun/wSQL
 public virtual void AutoIndentNeeded(object sender, AutoIndentEventArgs args)
 {
     var tb = (sender as FastColoredTextBox);
      Language language = tb.Language;
      switch (language)
      {
     case Language.CSharp:
        CSharpAutoIndentNeeded(sender, args);
        break;
     case Language.VB:
        VBAutoIndentNeeded(sender, args);
        break;
     case Language.HTML:
        HTMLAutoIndentNeeded(sender, args);
        break;
     case Language.XML:
        XMLAutoIndentNeeded(sender, args);
        break;
     case Language.SQL:
        SQLAutoIndentNeeded(sender, args);
        break;
     case Language.PHP:
        PHPAutoIndentNeeded(sender, args);
        break;
     case Language.JS:
        CSharpAutoIndentNeeded(sender, args);
        break; //JS like C#
     case Language.Lua:
        LuaAutoIndentNeeded(sender, args);
        break;
     case Language.wQL:
        //TODO: do we need auto ident for wQL?
        WQLAutoIndentNeeded(sender, args);
        break;
     default:
        break;
      }
 }
コード例 #28
0
        private void PascalAutoIndentNeeded(object sender, AutoIndentEventArgs args)
        {
            //start of declaration
            if (Regex.IsMatch(args.LineText, @"^\s*(begin|(case +\w+ +of)|( *= *record))\s*", RegexOptions.IgnoreCase))
            {
                //args.Shift = -args.TabLength;
                args.ShiftNextLines = args.TabLength;
                return;
            }

            //end of block
            if (Regex.IsMatch(args.LineText, @"^\s*(end\s*;?)\b", RegexOptions.IgnoreCase))
            {
                args.Shift = -args.TabLength;
                args.ShiftNextLines = -args.TabLength;
                return;
            }

            if (Regex.IsMatch(args.PrevLineText, @"^\s*(if|for|while|else)"))
                if (!Regex.IsMatch(args.PrevLineText, @"(;\s*$)|(;\s*//)"))//operator is unclosed
                {
                    args.Shift = args.TabLength;
                    return;
                }
        }
コード例 #29
0
 protected void PHPAutoIndentNeeded(object sender, AutoIndentEventArgs args)
 {
     var flag = Regex.IsMatch(args.LineText, "^[^\"']*\\{.*\\}[^\"']*$");
     if (!flag)
     {
         var flag2 = Regex.IsMatch(args.LineText, "^[^\"']*\\{");
         if (flag2)
         {
             args.ShiftNextLines = args.TabLength;
         }
         else
         {
             var flag3 = Regex.IsMatch(args.LineText, "}[^\"']*$");
             if (flag3)
             {
                 args.Shift = -args.TabLength;
                 args.ShiftNextLines = -args.TabLength;
             }
             else
             {
                 var flag4 = Regex.IsMatch(args.PrevLineText,
                     "^\\s*(if|for|foreach|while|[\\}\\s]*else)\\b[^{]*$");
                 if (flag4)
                 {
                     var flag5 = !Regex.IsMatch(args.PrevLineText, "(;\\s*$)|(;\\s*//)");
                     if (flag5)
                     {
                         args.Shift = args.TabLength;
                     }
                 }
             }
         }
     }
 }
コード例 #30
0
 protected void VBAutoIndentNeeded(object sender, AutoIndentEventArgs args)
 {
 }
コード例 #31
0
        private void HTMLAutoIndentNeeded(object sender, AutoIndentEventArgs args)
        {
            FastColoredTextBox tb = sender as FastColoredTextBox;

            tb.CalcAutoIndentShiftByCodeFolding(sender, args);
        }
コード例 #32
0
 public virtual void AutoIndentNeeded(AutoIndentEventArgs args)
 {
 }
コード例 #33
0
 public virtual void AutoIndentNeeded(object sender, AutoIndentEventArgs args)
 {
     var tb = (sender as FastColoredTextBox);
     Language language = tb.Language;
     switch (language)
     {
         case Language.CSharp:
             CSharpAutoIndentNeeded(sender, args);
             break;
         case Language.VB:
             VBAutoIndentNeeded(sender, args);
             break;
         case Language.HTML:
             HTMLAutoIndentNeeded(sender, args);
             break;
         case Language.XML:
             XMLAutoIndentNeeded(sender, args);
             break;
         case Language.SQL:
             SQLAutoIndentNeeded(sender, args);
             break;
         case Language.PHP:
             PHPAutoIndentNeeded(sender, args);
             break;
         case Language.JS:
             CSharpAutoIndentNeeded(sender, args);
             break; //JS like C#
         case Language.Lua:
             LuaAutoIndentNeeded(sender, args);
             break;
         case Language.Scp:
             ScpAutoIndentNeeded(sender, args);
             break;
         default:
             //MAIN.WriteLog("AutoIndentNeeded", MAIN.LoggerType.Error);
             break;
     }
 }
コード例 #34
0
 protected void XMLAutoIndentNeeded(object sender, AutoIndentEventArgs args)
 {
     var tb = sender as DocumentEditor;
     tb.CalcAutoIndentShiftByCodeFolding(sender, args);
 }
コード例 #35
0
 protected void LuaAutoIndentNeeded(object sender, AutoIndentEventArgs args)
 {
     var flag = Regex.IsMatch(args.LineText, "^\\s*(end|until)\\b");
     if (flag)
     {
         args.Shift = -args.TabLength;
         args.ShiftNextLines = -args.TabLength;
     }
     else
     {
         var flag2 = Regex.IsMatch(args.LineText, "\\b(then)\\s*\\S+");
         if (!flag2)
         {
             var flag3 = Regex.IsMatch(args.LineText, "^\\s*(function|do|for|while|repeat|if)\\b");
             if (flag3)
             {
                 args.ShiftNextLines = args.TabLength;
             }
             else
             {
                 var flag4 = Regex.IsMatch(args.LineText, "^\\s*(else|elseif)\\b", RegexOptions.IgnoreCase);
                 if (flag4)
                 {
                     args.Shift = -args.TabLength;
                 }
             }
         }
     }
 }
コード例 #36
0
 protected void XMLAutoIndentNeeded(object sender, AutoIndentEventArgs args)
 {
     var fastColoredTextBox = sender as FastColoredTextBox;
     fastColoredTextBox.CalcAutoIndentShiftByCodeFolding(sender, args);
 }
コード例 #37
0
        public override void AutoIndentNeeded(object sender, AutoIndentEventArgs args)
        {
            var tb = sender as FastColoredTextBox;

            tb.CalcAutoIndentShiftByCodeFolding(sender, args);
        }
コード例 #38
0
 private void fctb_AutoIndentNeeded(object sender, AutoIndentEventArgs e)
 {
     //we assign this handler to disable AutoIndent by folding
 }
コード例 #39
0
        private void LuaAutoIndentNeeded(object sender, AutoIndentEventArgs args)
        {
            //end of block
            if (Regex.IsMatch(args.LineText, @"^\s*(end|until)\b"))
            {
                args.Shift = -args.TabLength;
                args.ShiftNextLines = -args.TabLength;
                return;
            }
            // then ...
            if (Regex.IsMatch(args.LineText, @"\b(then)\s*\S+"))
                return;
            //start of operator block
            if (Regex.IsMatch(args.LineText, @"^\s*(function|do|for|while|repeat|if)\b"))
            {
                args.ShiftNextLines = args.TabLength;
                return;
            }

            //Statements else, elseif, case etc
            if (Regex.IsMatch(args.LineText, @"^\s*(else|elseif)\b", RegexOptions.IgnoreCase))
            {
                args.Shift = -args.TabLength;
            }
        }
コード例 #40
0
        public virtual void AutoIndentNeeded(object sender, AutoIndentEventArgs args)
        {
            var tb = (sender as FastColoredTextBox);
            Language language = tb.Language;
            switch (language)
            {
                case Language.C:
                    CAutoIndentNeeded(sender, args);
                    break;

                default:
                    break;
            }
        }
コード例 #41
0
 private void RubyAutoIndentNeeded(object sender, AutoIndentEventArgs args)
 {
     if (Regex.IsMatch(args.LineText, @"^\s*(end)\b"))
     {
         args.Shift = -args.TabLength;
         args.ShiftNextLines = -args.TabLength;
         return;
     }
     if (Regex.IsMatch(args.LineText, @"\b(then)\s*\S+"))
         return;
     if (Regex.IsMatch(args.LineText, @"^\s*(else|elsif)\b", RegexOptions.IgnoreCase))
     {
         args.Shift = -args.TabLength;
         return;
     }
     if (Regex.IsMatch(args.LineText, @"\b(def|if|for|class|case|when)\b"))
     {
         args.ShiftNextLines = args.TabLength;
     }
 }
コード例 #42
0
ファイル: Home.cs プロジェクト: Ganeshsubramaniyam/TechnoTurn
        public void save_notification_on_tab(object sender, AutoIndentEventArgs args)
        {
            string tempfilename = tabControl1.SelectedTabPage.Text;

            tabControl1.SelectedTabPage.Text = tempfilename + "*";
        }
コード例 #43
0
        private void VBAutoIndentNeeded(object sender, AutoIndentEventArgs args)
        {
            //end of block
            if (Regex.IsMatch(args.LineText, @"^\s*(End|EndIf|Next|Loop)\b", RegexOptions.IgnoreCase))
            {
                args.Shift = -args.TabLength;
                args.ShiftNextLines = -args.TabLength;
                return;
            }
            //start of declaration
            if (Regex.IsMatch(args.LineText,
                @"\b(Class|Property|Enum|Structure|Sub|Function|Namespace|Interface|Get)\b|(Set\s*\()",
                RegexOptions.IgnoreCase))
            {
                args.ShiftNextLines = args.TabLength;
                return;
            }
            // then ...
            if (Regex.IsMatch(args.LineText, @"\b(Then)\s*\S+", RegexOptions.IgnoreCase))
                return;
            //start of operator block
            if (Regex.IsMatch(args.LineText, @"^\s*(If|While|For|Do|Try|With|Using|Select)\b", RegexOptions.IgnoreCase))
            {
                args.ShiftNextLines = args.TabLength;
                return;
            }

            //Statements else, elseif, case etc
            if (Regex.IsMatch(args.LineText, @"^\s*(Else|ElseIf|Case|Catch|Finally)\b", RegexOptions.IgnoreCase))
            {
                args.Shift = -args.TabLength;
                return;
            }

            //Char _
            if (args.PrevLineText.TrimEnd().EndsWith("_"))
            {
                args.Shift = args.TabLength;
            }
        }
コード例 #44
0
ファイル: Form1.cs プロジェクト: qrai/VoltDev
 private void fastColoredTextBox1_AutoIndentNeeded(object sender, AutoIndentEventArgs e)
 {
 }
コード例 #45
0
ファイル: FileManager.cs プロジェクト: remco138/amanda
        private void _AutoIndentNeeded(object sender, AutoIndentEventArgs e)
        {
            Match isOtherwiseRegex = Regex.Match(e.LineText.Trim(), ",* otherwise");
            int currentIndent = e.LineText.TakeWhile(q => q == ' ').Count();    //shouldn't be too inefficient
            int at = e.LineText.IndexOf('=');

            AmandaTagParser tagParser = new AmandaTagParser();
            tagParser.Parse(textBox.Text);

            /*
             *              All these todo's might not be neccessary, it's pretty good right now
             */
            //If the line contains a where, we want the next lines to be indented by a tab
            if (Regex.IsMatch(e.LineText, "where"))
            {
                e.ShiftNextLines = e.TabLength;
            }

            //if the line is a condition, we want to find the '=' and indent to there, that's how youre supposed to do conditions in amanda
            else if (Regex.IsMatch(e.LineText.Trim(), ",* if"))
            {
                e.ShiftNextLines = at - currentIndent;
            }

            //If line is empty | prev line is empty | contains otherwise (which indicates the end of an if/else statement)
            else if (e.LineText.Trim() == "" || e.PrevLineText.Trim().Count() == 0 || Regex.IsMatch(e.LineText.Trim(), ",* otherwise") == true)
            {
                //Get the tag based on our current line, if we are at line 3, and there is a big function going from line 1-5, it will return that.
                AmandaTag tag = tagParser.GetTag(e.iLine);
                if (tag != null)
                {
                    e.ShiftNextLines = tag.BeginLocation.X - at;
                }

                //No function found? No problem, resort to a tab
                else
                {
                    e.ShiftNextLines = -e.TabLength;
                }
            }
        }
コード例 #46
0
 public virtual void AutoIndentNeeded(object sender, AutoIndentEventArgs args)
 {
     var tb = (sender as FastColoredTextBox);
     var language = tb.Language;
     switch (language)
     {
         case Language.CSharp:
             CSharpAutoIndentNeeded(sender, args);
             break;
         case Language.Vb:
             VbAutoIndentNeeded(sender, args);
             break;
         case Language.Html:
             HtmlAutoIndentNeeded(sender, args);
             break;
         case Language.Xml:
             XmlAutoIndentNeeded(sender, args);
             break;
         case Language.Sql:
             SqlAutoIndentNeeded(sender, args);
             break;
         case Language.Php:
             PhpAutoIndentNeeded(sender, args);
             break;
         case Language.Js:
             CSharpAutoIndentNeeded(sender, args);
             break; //JS like C#
         case Language.Lua:
             LuaAutoIndentNeeded(sender, args);
             break;
         default:
             break;
     }
 }