Skip to content

Commit

Permalink
Added sections background toggle preference
Browse files Browse the repository at this point in the history
  • Loading branch information
maccasoft committed Feb 26, 2023
1 parent b27d5ca commit cfaa51a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
12 changes: 12 additions & 0 deletions modules/spin-tools/src/com/maccasoft/propeller/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class Preferences {
public static final String PROP_EDITOR_FONT = "editorFont";
public static final String PROP_SHOW_INDENT_LINES = "showIndentLines";
public static final String PROP_INDENT_LINES_SIZE = "showLinesSize";
public static final String PROP_SHOW_SECTIONS_BACKGROUND = "showSectionsBackground";
public static final String PROP_SHOW_EDITOR_OUTLINE = "showEditorOutline";
public static final String PROP_LRU = "lru";
public static final String PROP_PORT = "port";
Expand Down Expand Up @@ -131,6 +132,7 @@ public SerializedPreferences() {
public boolean showLineNumbers;
public String editorFont;
public boolean showIndentLines;
public Boolean showSectionsBackground;
public int indentLinesSize;
public boolean showEditorOutline;
public String port;
Expand Down Expand Up @@ -323,6 +325,16 @@ public void setIndentLinesSize(int indentLinesSize) {
changeSupport.firePropertyChange(PROP_INDENT_LINES_SIZE, preferences.indentLinesSize, preferences.indentLinesSize = indentLinesSize);
}

public boolean getShowSectionsBackground() {
return preferences.showSectionsBackground != null ? preferences.showSectionsBackground : true;
}

public void setShowSectionsBackground(boolean showSectionsBackground) {
boolean oldValue = getShowSectionsBackground();
preferences.showSectionsBackground = showSectionsBackground ? null : showSectionsBackground;
changeSupport.firePropertyChange(PROP_SHOW_SECTIONS_BACKGROUND, oldValue, showSectionsBackground);
}

public boolean getShowEditorOutline() {
return preferences.showEditorOutline;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class PreferencesDialog extends Dialog {
TabStops objTabStops;
TabStops pubTabStops;
TabStops datTabStops;
Button showSectionsBackground;

PathList spin1Paths;
Button spin1CaseSensitive;
Expand All @@ -93,6 +94,7 @@ public class PreferencesDialog extends Dialog {
String oldEditorFont;
boolean oldShowLineNumbers;
boolean oldShowIndentLines;
boolean oldShowSectionsBackground;
boolean oldShowEditorOutline;
boolean oldSpin1CaseSensitive;
boolean oldSpin2CaseSensitive;
Expand Down Expand Up @@ -349,6 +351,7 @@ public void widgetSelected(SelectionEvent e) {
oldShowLineNumbers = preferences.getShowLineNumbers();
oldShowIndentLines = preferences.getShowIndentLines();
oldShowEditorOutline = preferences.getShowEditorOutline();
oldShowSectionsBackground = preferences.getShowSectionsBackground();
oldSpin1CaseSensitive = preferences.getSpin1CaseSensitiveSymbols();
oldSpin2CaseSensitive = preferences.getSpin2CaseSensitiveSymbols();
oldTerminalFont = preferences.getTerminalFont();
Expand Down Expand Up @@ -623,6 +626,19 @@ public void widgetSelected(SelectionEvent e) {
}
});

new Label(composite, SWT.NONE);

showSectionsBackground = new Button(composite, SWT.CHECK);
showSectionsBackground.setText("Show sections background");
showSectionsBackground.setSelection(preferences.getShowSectionsBackground());
showSectionsBackground.addSelectionListener(new SelectionAdapter() {

@Override
public void widgetSelected(SelectionEvent e) {
preferences.setShowSectionsBackground(showSectionsBackground.getSelection());
}
});

Group group = new Group(composite, SWT.NONE);
group.setText("Tab stops");
group.setLayout(new GridLayout(2, false));
Expand Down Expand Up @@ -784,15 +800,20 @@ Composite createPage(Composite parent, String text) {
protected void cancelPressed() {
preferences.setShowObjectBrowser(oldShowObjectBrowser);
preferences.setShowBrowser(oldShowBrowser);

preferences.setEditorFont(oldEditorFont);
preferences.setShowLineNumbers(oldShowLineNumbers);
preferences.setShowIndentLines(oldShowIndentLines);
preferences.setShowEditorOutline(oldShowEditorOutline);
preferences.setShowSectionsBackground(oldShowSectionsBackground);

preferences.setSpin1CaseSensitiveSymbols(oldSpin1CaseSensitive);
preferences.setSpin2CaseSensitiveSymbols(oldSpin2CaseSensitive);

preferences.setTerminalFont(oldTerminalFont);
preferences.setTerminalLineInput(oldTerminalLineInput);
preferences.setTerminalLocalEcho(oldTerminalLocalEcho);

super.cancelPressed();
}

Expand All @@ -808,6 +829,7 @@ protected void okPressed() {

preferences.setSpin1LibraryPath(spin1Paths.getFileItems());
preferences.setSpin2LibraryPath(spin2Paths.getFileItems());

super.okPressed();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ public void propertyChange(PropertyChangeEvent evt) {
outline.setVisible((Boolean) evt.getNewValue());
sashForm.layout(true);
break;
case Preferences.PROP_SHOW_SECTIONS_BACKGROUND:
styledText.redraw();
break;
}
}
};
Expand Down Expand Up @@ -613,7 +616,9 @@ public void lineGetStyle(LineStyleEvent event) {

@Override
public void lineGetBackground(LineBackgroundEvent event) {
event.lineBackground = getLineBackground(tokenMarker.getRoot(), event.lineOffset);
if (preferences.getShowSectionsBackground()) {
event.lineBackground = getLineBackground(tokenMarker.getRoot(), event.lineOffset);
}
if (styledText.getLineAtOffset(event.lineOffset) == currentLine) {
if (event.lineBackground != null) {
event.lineBackground = ColorRegistry.getDimColor(event.lineBackground, -6);
Expand Down

0 comments on commit cfaa51a

Please sign in to comment.