Changeset 4065


Ignore:
Timestamp:
Jan 29, 2009, 7:49:28 PM (12 years ago)
Author:
yura
Message:
Location:
devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/editor/RfpAutoIndentStrategy.java

    r3870 r4065  
    1616    private boolean autoindentNewline;
    1717    private boolean autocloseBraces;
    18     private static String indentation;
     18    private String indentation;
    1919
    2020    public RfpAutoIndentStrategy (final IPreferenceStore store) {
     
    3232                else if (IPreferenceConstants.AUTOCLOSE_BRACES.equals(property))
    3333                    autocloseBraces = store.getBoolean(IPreferenceConstants.AUTOCLOSE_BRACES);
    34                 else if (IPreferenceConstants.SPACES_FOR_TABS.equals(property) ||
    35                         IPreferenceConstants.TAB_WIDTH.equals(property))
     34                else if (IPreferenceConstants.SPACES_FOR_TABS.equals(property)
     35                        || IPreferenceConstants.TAB_WIDTH.equals(property))
    3636                    indentation = blockIndentation(store);
    3737            }
     
    5252                return;
    5353            }
    54                 if (isInsertNewLineCommand(document, command)) {
     54            if (isInsertNewLineCommand(document, command)) {
    5555                if (partType == IRfpPartitions.MULTI_LINE_COMMENT)
    5656                    return;
     
    5858                    command.text += autoIndentAfterNewLine(document, offset);
    5959                if (partType == IRfpPartitions.WORD)
    60                     command.text = '\"' + command.text + '\"'; 
     60                    command.text = '\"' + command.text + '\"';
    6161                else if (partType == IRfpPartitions.CHARACTER)
    62                     command.text = '\'' + command.text + '\'';
    63                 else if (partType == IDocument.DEFAULT_CONTENT_TYPE && noRightBrace(document, offset) && autocloseBraces) {
     62                    command.text = '\'' + command.text + '\'';
     63                else if (partType == IDocument.DEFAULT_CONTENT_TYPE && noRightBrace(document, offset)
     64                        && autocloseBraces) {
    6465                    command.caretOffset = command.offset + command.text.length();
    6566                    command.shiftsCaret = false;
    66                     command.text += TextUtilities.getDefaultLineDelimiter(document) + getRightBraceIndent(document, offset) + '}';
     67                    command.text += TextUtilities.getDefaultLineDelimiter(document)
     68                            + getRightBraceIndent(document, offset) + '}';
    6769                }
    68                    
     70
    6971            }
    7072        } catch (BadLocationException e) {
     
    7274        }
    7375    }
    74    
    7576
    7677    private static boolean noRightBrace (IDocument document, int offset) throws BadLocationException {
     
    9798    }
    9899
    99 
    100100    private static boolean isInsertNewLineCommand (IDocument document, DocumentCommand command) {
    101101        if (command.length != 0)
     
    108108    }
    109109
    110     public static String autoIndentAfterNewLine (IDocument document, int offset) throws BadLocationException {
     110    public String autoIndentAfterNewLine (IDocument document, int offset) throws BadLocationException {
    111111        if (document.getLength() == 0)
    112112            return "";
     
    188188        boolean spaces = store.getBoolean(IPreferenceConstants.SPACES_FOR_TABS);
    189189        int tabWidth = store.getInt(IPreferenceConstants.TAB_WIDTH);
    190         if (spaces) {
     190        if (spaces)
    191191            switch (tabWidth) {
    192192                case 0: return "";
     
    203203                    for (; tabWidth > 0; tabWidth--)
    204204                        sb.append(' ');
    205                     return new  String(sb);
    206             }
    207         }
     205                    return new String(sb);
     206            }
    208207        else
    209208            return "\t";
  • devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/editor/RfpEditor.java

    r4054 r4065  
    135135    private final BracketMatcher bracketMatcher;
    136136    private IPropertyChangeListener propertyChangeListener;
    137     private RfpSourceViewerConfiguration rfpSourceViewerConfiguration;
     137    private RfpAutoIndentStrategy rfpAutoIndentStrategy;
    138138    private IPreferenceStore store;
    139139    RfpPreferences preferences;
     
    167167        preferences = new RfpPreferences(store);
    168168
    169         rfpSourceViewerConfiguration = new RfpSourceViewerConfiguration(this, store);
    170         setSourceViewerConfiguration(rfpSourceViewerConfiguration);
     169        rfpAutoIndentStrategy = new RfpAutoIndentStrategy(store);
     170        setSourceViewerConfiguration(new RfpSourceViewerConfiguration(this, rfpAutoIndentStrategy, store));
    171171
    172172        bracketInserter = new BracketInserter(this, store);
     
    315315    }
    316316
     317    public RfpAutoIndentStrategy getRfpAutoIndentStrategy () {
     318        return rfpAutoIndentStrategy;
     319    }
     320
    317321    public int widgetOffset2ModelOffset (int offset) {
    318322        return widgetOffset2ModelOffset(getSourceViewer(), offset);
  • devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/editor/RfpSourceViewerConfiguration.java

    r3874 r4065  
    3232    private final IAutoEditStrategy[] autoIngentStrategies;
    3333
    34     public RfpSourceViewerConfiguration (RfpEditor editor, IPreferenceStore store) {
     34    public RfpSourceViewerConfiguration (RfpEditor editor, RfpAutoIndentStrategy rfpAutoIndentStrategy,
     35            IPreferenceStore store) {
    3536        super(store);
    3637        this.editor = editor;
    37         autoIngentStrategies = new IAutoEditStrategy[] { new RfpAutoIndentStrategy(store) };
     38        autoIngentStrategies = new IAutoEditStrategy[] { rfpAutoIndentStrategy };
    3839    }
    3940
  • devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/ui/actions/IndentAction.java

    r3862 r4065  
    5555                                text = RfpAutoIndentStrategy.getRightBraceIndent(document, offset);
    5656                            else
    57                                 text = RfpAutoIndentStrategy.autoIndentAfterNewLine(document, lineOffset);
     57                                text = editor.getRfpAutoIndentStrategy().autoIndentAfterNewLine(document, lineOffset);
    5858                            document.replace(lineOffset, offset - lineOffset, text);
    5959                        }
Note: See TracChangeset for help on using the changeset viewer.