Changeset 1138


Ignore:
Timestamp:
Jul 2, 2011, 2:26:01 PM (6 years ago)
Author:
stefan
Message:

invalid environment closing is marked as error while typing

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/CHANGELOG

    r1137 r1138  
    1616  - replaced buggy Java open dialog with a completely new one - better looking and better usability
    1717  - improved math environment detection and error highlighting
     18  - invalid environment closing is marked as error while typing
    1819* minor enhancements:
    1920  - prettied up tabs and icons in compile tree
  • trunk/data/codehelper/commands.xml

    r961 r1138  
    908908
    909909  <command name="\begin" usage="\begin{@environment@}@|@&nl;\end{@environment@}" hint="paragraph-making environments" style="begin">
    910     <argument name="environment">
     910    <argument name="environment" type="opening_env">
    911911      <argumentValue value="abstract"/>
    912912      <argumentValue value="array"/>
     
    940940
    941941  <command name="\end" usage="\end{@environment@}" hint="closing environment" style="begin">
    942     <argument name="environment"/>
     942    <argument name="environment" type="closing_env"/>
    943943  </command>
    944944
  • trunk/data/styles/user.xml

    r1054 r1138  
    3737  <element name="cite_not_found" style="plain" foreground="ff0000"/>
    3838
     39  <element name="env_name" style="plain" foreground="0000FF"/>
     40
    3941</styles>
  • trunk/src/jlatexeditor/syntaxhighlighting/LatexSyntaxHighlighting.java

    r1137 r1138  
    66
    77import jlatexeditor.codehelper.BackgroundParser;
     8import jlatexeditor.syntaxhighlighting.states.Env;
    89import jlatexeditor.syntaxhighlighting.states.MathMode;
    910import jlatexeditor.syntaxhighlighting.states.RootState;
     
    2324import java.util.Arrays;
    2425import java.util.Iterator;
     26import java.util.Stack;
    2527import java.util.regex.Matcher;
    2628import java.util.regex.Pattern;
     
    305307                });
    306308                char_nr += param.length();
     309              } else
     310              if (argumentTypeName.equals("opening_env")) {
     311                stateStack.push(new Env(param, false, state));
     312                byte style = stateStyles[getStyle("env_name", LatexStyles.TEXT)];
     313                char_nr = setStyle(param, style, chars, char_nr + 1);
     314              } else
     315              if (argumentTypeName.equals("closing_env")) {
     316                if (state instanceof Env) {
     317                  Env openingEnv = (Env) state;
     318                  Env closingEnv = new Env(param, true, state);
     319                  boolean validClosing = false;
     320                  if (closingEnv.closes(openingEnv)) {
     321                    stateStack.pop();
     322                    state = stateStack.peek();
     323                    validClosing = true;
     324                  }
     325                  byte style = stateStyles[getStyle(validClosing ? "env_name" : "error", LatexStyles.TEXT)];
     326                  char_nr = setStyle(param, style, chars, char_nr + 1);
     327                }
    307328              }
    308329            }
Note: See TracChangeset for help on using the changeset viewer.