]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/Preferences.java
Limit SCL Console buffer size to 5M characters by default
[simantics/platform.git] / bundles / org.simantics.scl.ui / src / org / simantics / scl / ui / console / Preferences.java
index a9d76a2f0839d1ea0d04a2a7a167c3d45fc67c8c..6b733146b8105254571afebaa7d232d6da0c316d 100644 (file)
@@ -12,12 +12,45 @@ import java.util.TreeSet;
  */
 public final class Preferences {
 
-    public static final String  COMMAND_HISTORY = "COMMAND_HISTORY";
+    /**
+     * Console buffer high and low water marks
+     */
+    public static final String CONSOLE_LIMIT_CONSOLE_OUTPUT = "SCLConsole.limitConsoleOutput";       //$NON-NLS-1$
 
-    private static final String DELIMITER       = "¤¤¤¤";
+    public static final String CONSOLE_LOW_WATER_MARK       = "SCLConsole.lowWaterMark";             //$NON-NLS-1$
+
+    public static final String CONSOLE_HIGH_WATER_MARK      = "SCLConsole.highWaterMark";            //$NON-NLS-1$
+
+    /**
+     * By default console output buffer size is limited.
+     */
+    public static final boolean CONSOLE_LIMIT_CONSOLE_OUTPUT_DEFAULT = true;
+
+    /**
+     * The console low water mark default value {@value #CONSOLE_LOW_WATER_MARK_DEFAULT_VALUE}.
+     */
+    public static final int CONSOLE_LOW_WATER_MARK_DEFAULT_VALUE = 5000000;
+
+    /**
+     * The console low water mark default value {@value #CONSOLE_HIGH_WATER_MARK_DEFAULT_VALUE}.
+     */
+    public static final int CONSOLE_HIGH_WATER_MARK_DEFAULT_VALUE = highWatermarkForLow(CONSOLE_LOW_WATER_MARK_DEFAULT_VALUE);
+
+    /**
+     * The console low water mark maximum value {@value #CONSOLE_LOW_WATER_MARK_MAX_VALUE}.
+     */
+    public static final int CONSOLE_LOW_WATER_MARK_MAX_VALUE = 10000000;
+
+    public static int highWatermarkForLow(int low) {
+        return low + 80*100;
+    }
+
+    public static final String  COMMAND_HISTORY = "COMMAND_HISTORY"; //$NON-NLS-1$
+
+    private static final String DELIMITER       = "¤¤¤¤"; //$NON-NLS-1$
 
     public static String join(Collection<String> s, String delimiter) {
-        if (s == null || s.isEmpty()) return "";
+        if (s == null || s.isEmpty()) return ""; //$NON-NLS-1$
         Iterator<String> iter = s.iterator();
         StringBuilder builder = new StringBuilder(iter.next());
         while( iter.hasNext() )