diff --git a/CHANGELOG.md b/CHANGELOG.md index 004fd09a1..ed6003f51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,12 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Added +- Configurable tab size (formatting must be set to use tabs) - default matches indent size of 3 + ### Fixed - [#2021], [#2000] Caret position in editors when using tabs and / or unicode -- Script editors - tab size now matches indent size +- [#2021] Indent continuation when using tabs ## [20.0.0] - 2023-11-05 ### Added diff --git a/lib/jsyntaxpane-0.9.5.jar b/lib/jsyntaxpane-0.9.5.jar index bfd9ec51f..5564083bf 100644 Binary files a/lib/jsyntaxpane-0.9.5.jar and b/lib/jsyntaxpane-0.9.5.jar differ diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java index 38f4dc841..bff711194 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -971,6 +971,11 @@ public final class Configuration { @ConfigurationDefaultBoolean(false) @ConfigurationCategory("export") public static ConfigurationItem flaExportUseMappedFontLayout = null; + + @ConfigurationDefaultInt(3) + @ConfigurationName("formatting.tab.size") + @ConfigurationCategory("format") + public static ConfigurationItem tabSize = null; private enum OSId { WINDOWS, OSX, UNIX diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/java/jsyntaxpane/actions/ActionUtils.java b/libsrc/jsyntaxpane/jsyntaxpane/src/main/java/jsyntaxpane/actions/ActionUtils.java index 97188ceab..a66501319 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/java/jsyntaxpane/actions/ActionUtils.java +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/java/jsyntaxpane/actions/ActionUtils.java @@ -73,7 +73,7 @@ public class ActionUtils { return ""; } int i = 0; - while (i < line.length() && line.charAt(i) == ' ') { + while (i < line.length() && (line.charAt(i) == ' ' || line.charAt(i) == '\t')) { //JPEXS: added '\t' i++; } return line.substring(0, i); @@ -553,12 +553,24 @@ public class ActionUtils { target.setCaretPosition(p); } + //JPEXS + public static boolean usesTabs(JTextComponent target) { + Object prop = target.getDocument().getProperty("jpexs:useTabs"); + if (prop != null) { + return (Boolean) prop; + } + return false; + } + /** * Return a string with number of spaces equal to the tab-stop of the TextComponent * @param target * @return */ public static String getTab(JTextComponent target) { + if (usesTabs(target)) { //JPEXS + return "\t"; + } return SPACES.substring(0, getTabSize(target)); } diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/java/jsyntaxpane/actions/IndentAction.java b/libsrc/jsyntaxpane/jsyntaxpane/src/main/java/jsyntaxpane/actions/IndentAction.java index 90d7ccb4a..8b1f89d76 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/java/jsyntaxpane/actions/IndentAction.java +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/java/jsyntaxpane/actions/IndentAction.java @@ -55,7 +55,11 @@ public class IndentAction extends DefaultSyntaxAction { int column = dot - lineStart; int needed = tabStop - (column % tabStop); if (abbrvs == null || abbrToken == null) { - target.replaceSelection(ActionUtils.SPACES.substring(0, needed)); + if (ActionUtils.usesTabs(target)) { //JPEXS + target.replaceSelection("\t"); + } else { + target.replaceSelection(ActionUtils.SPACES.substring(0, needed)); + } } else { String abbr = abbrToken.getString(sDoc); if (abbrvs.containsKey(abbr)) { @@ -68,7 +72,11 @@ public class IndentAction extends DefaultSyntaxAction { ActionUtils.insertSimpleTemplate(target, abbr); } } else { - target.replaceSelection(ActionUtils.SPACES.substring(0, needed)); + if (ActionUtils.usesTabs(target)) { //JPEXS + target.replaceSelection("\t"); + } else { + target.replaceSelection(ActionUtils.SPACES.substring(0, needed)); + } } } } else { diff --git a/src/com/jpexs/decompiler/flash/gui/editor/UndoFixedEditorPane.java b/src/com/jpexs/decompiler/flash/gui/editor/UndoFixedEditorPane.java index b42d01426..57fbf33f3 100644 --- a/src/com/jpexs/decompiler/flash/gui/editor/UndoFixedEditorPane.java +++ b/src/com/jpexs/decompiler/flash/gui/editor/UndoFixedEditorPane.java @@ -163,7 +163,8 @@ public class UndoFixedEditorPane extends JEditorPane { ((SyntaxDocument) doc).setIgnoreUpdate(false); } - doc.putProperty(PlainDocument.tabSizeAttribute, Configuration.indentSize.get()); + doc.putProperty(PlainDocument.tabSizeAttribute, Configuration.tabSize.get()); + doc.putProperty("jpexs:useTabs", Configuration.indentUseTabs.get()); setDocument(doc); } catch (BadLocationException | IOException ex) { diff --git a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties index 7b0d76e23..f648f75bc 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties @@ -743,3 +743,8 @@ config.description.displayAs3PCodePanel = Show panel with disassembled P-code in config.name.flaExportUseMappedFontLayout = FLA export - use mapped font layout config.description.flaExportUseMappedFontLayout = Use assigned source font advance values when determining letterspacing when actual font has no layout during FLA export. + +#after 20.0.0 + +config.name.formatting.tab.size = Tab size +config.description.formatting.tab.size = Number of spaces per tab \ No newline at end of file diff --git a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_cs.properties b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_cs.properties index 66237ab18..1893d6532 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_cs.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_cs.properties @@ -733,3 +733,8 @@ config.description.displayAs3PCodePanel = Zobrazit panel s instrukcemi disassemb config.name.flaExportUseMappedFontLayout = FLA export - pou\u017e\u00edvat namapovan\u00e9 rozvr\u017een\u00ed p\u00edsem config.description.flaExportUseMappedFontLayout = B\u011bhem FLA exportu pou\u017e\u00edvat advance hodnoty z p\u0159i\u0159azen\u00e9ho zdrojov\u00e9ho p\u00edsma p\u0159i ur\u010dov\u00e1n\u00ed letterspacing hodnoty kdy\u017e vlastn\u00ed p\u00edsmo nem\u00e1 rozvr\u017een\u00ed + +#after 20.0.0 + +config.name.formatting.tab.size = Velikost tabel\u00e1toru +config.description.formatting.tab.size = Po\u010det mezer v tabel\u00e1toru \ No newline at end of file