[Swift-commit] r7306 - trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Fri Nov 22 15:12:59 CST 2013


Author: hategan
Date: 2013-11-22 15:12:59 -0600 (Fri, 22 Nov 2013)
New Revision: 7306

Modified:
   trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/ScreenBuffer.java
Log:
do a full sync of the screen buffer once in a while just in case some regions get dirty on the client side

Modified: trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/ScreenBuffer.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/ScreenBuffer.java	2013-11-22 21:03:35 UTC (rev 7305)
+++ trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/ScreenBuffer.java	2013-11-22 21:12:59 UTC (rev 7306)
@@ -31,6 +31,10 @@
 	public static final int ATTR_MASK_FG_COLOR = 0x000f0000;
 	public static final int ATTR_MASK_BG_COLOR = 0x00f00000;
 	
+	// every 10 seconds send the full buffer in case the terminal
+	// garbles up parts of the screen
+	public static final int FULL_SYNC_INTERVAL = 10000;
+	
 	private int width, height;
 	private int[] actual;
 	private int[] buf, tmp;
@@ -40,6 +44,7 @@
 	private boolean lineArt;
 	private CountingWriter os;
 	private int lastattr;
+	private long lastFullSyncTime;
 
 	public ScreenBuffer(ANSIContext context, int width, int height) {
 		this.context = context;
@@ -142,10 +147,17 @@
 			lastattr = attrs();
 			setAttrs(lastattr);
 		}
+		
+		boolean fullSync = false;
+		long now = System.currentTimeMillis();
+		if (now - this.lastFullSyncTime > FULL_SYNC_INTERVAL) {
+		    this.lastFullSyncTime = now;
+		    fullSync = true;
+		}
 		for (int y = 0; y < height; y++) {
 			for (int x = 0; x < width; x++) {
 				int b = tmp[p];
-				if (b != actual[p]) {
+				if ((b != actual[p]) || fullSync) {
 					int attr = b & 0xffff0000;
 					updateAttr(attr, lastattr);
 					lastattr = attr;




More information about the Swift-commit mailing list