aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenny Root <kenny@the-b.org>2009-06-20 01:43:34 +0000
committerKenny Root <kenny@the-b.org>2009-06-20 01:43:34 +0000
commit67be2e8f774872dd3923ddd75a15b91911888d28 (patch)
tree994fd773193111de8eda1913d364bcb400748a9b /src
parente77f48d5bc1dab117b7aaca4bb967a3c9f473b45 (diff)
downloadconnectbot-67be2e8f774872dd3923ddd75a15b91911888d28.tar.gz
connectbot-67be2e8f774872dd3923ddd75a15b91911888d28.tar.bz2
connectbot-67be2e8f774872dd3923ddd75a15b91911888d28.zip
Synchronize terminal resizing
git-svn-id: https://connectbot.googlecode.com/svn/trunk/connectbot@319 df292f66-193f-0410-a5fc-6d59da041ff2
Diffstat (limited to 'src')
-rw-r--r--src/org/connectbot/service/TerminalBridge.java138
1 files changed, 71 insertions, 67 deletions
diff --git a/src/org/connectbot/service/TerminalBridge.java b/src/org/connectbot/service/TerminalBridge.java
index 9e8d4be..f81e3a5 100644
--- a/src/org/connectbot/service/TerminalBridge.java
+++ b/src/org/connectbot/service/TerminalBridge.java
@@ -908,11 +908,13 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener {
try {
// request a terminal pty resize
- int prevRow = buffer.getCursorRow();
- buffer.setScreenSize(columns, rows, true);
+ synchronized (buffer) {
+ int prevRow = buffer.getCursorRow();
+ buffer.setScreenSize(columns, rows, true);
- // Work around weird vt320.java behavior where cursor is an offset from the bottom??
- buffer.setCursorPosition(buffer.getCursorColumn(), prevRow);
+ // Work around weird vt320.java behavior where cursor is an offset from the bottom??
+ buffer.setCursorPosition(buffer.getCursorColumn(), prevRow);
+ }
if(transport != null)
transport.setDimensions(columns, rows, width, height);
@@ -964,80 +966,82 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener {
public void onDraw() {
int fg, bg;
- boolean entireDirty = buffer.update[0] || fullRedraw;
-
- // walk through all lines in the buffer
- for(int l = 0; l < buffer.height; l++) {
-
- // check if this line is dirty and needs to be repainted
- // also check for entire-buffer dirty flags
- if (!entireDirty && !buffer.update[l + 1]) continue;
-
- // reset dirty flag for this line
- buffer.update[l + 1] = false;
-
- // walk through all characters in this line
- for (int c = 0; c < buffer.width; c++) {
- int addr = 0;
- int currAttr = buffer.charAttributes[buffer.windowBase + l][c];
-
- // reset default colors
- fg = color[COLOR_FG_STD];
- bg = color[COLOR_BG_STD];
-
- // check if foreground color attribute is set
- if ((currAttr & VDUBuffer.COLOR_FG) != 0) {
- int fgcolor = ((currAttr & VDUBuffer.COLOR_FG) >> VDUBuffer.COLOR_FG_SHIFT) - 1;
- if (fgcolor < 8 && (currAttr & VDUBuffer.BOLD) != 0)
- fg = color[fgcolor + 8];
- else
- fg = color[fgcolor];
- }
+ synchronized (buffer) {
+ boolean entireDirty = buffer.update[0] || fullRedraw;
+
+ // walk through all lines in the buffer
+ for(int l = 0; l < buffer.height; l++) {
+
+ // check if this line is dirty and needs to be repainted
+ // also check for entire-buffer dirty flags
+ if (!entireDirty && !buffer.update[l + 1]) continue;
+
+ // reset dirty flag for this line
+ buffer.update[l + 1] = false;
+
+ // walk through all characters in this line
+ for (int c = 0; c < buffer.width; c++) {
+ int addr = 0;
+ int currAttr = buffer.charAttributes[buffer.windowBase + l][c];
+
+ // reset default colors
+ fg = color[COLOR_FG_STD];
+ bg = color[COLOR_BG_STD];
+
+ // check if foreground color attribute is set
+ if ((currAttr & VDUBuffer.COLOR_FG) != 0) {
+ int fgcolor = ((currAttr & VDUBuffer.COLOR_FG) >> VDUBuffer.COLOR_FG_SHIFT) - 1;
+ if (fgcolor < 8 && (currAttr & VDUBuffer.BOLD) != 0)
+ fg = color[fgcolor + 8];
+ else
+ fg = color[fgcolor];
+ }
- // check if background color attribute is set
- if ((currAttr & VDUBuffer.COLOR_BG) != 0)
- bg = color[((currAttr & VDUBuffer.COLOR_BG) >> VDUBuffer.COLOR_BG_SHIFT) - 1];
+ // check if background color attribute is set
+ if ((currAttr & VDUBuffer.COLOR_BG) != 0)
+ bg = color[((currAttr & VDUBuffer.COLOR_BG) >> VDUBuffer.COLOR_BG_SHIFT) - 1];
- // support character inversion by swapping background and foreground color
- if ((currAttr & VDUBuffer.INVERT) != 0) {
- int swapc = bg;
- bg = fg;
- fg = swapc;
- }
+ // support character inversion by swapping background and foreground color
+ if ((currAttr & VDUBuffer.INVERT) != 0) {
+ int swapc = bg;
+ bg = fg;
+ fg = swapc;
+ }
- // set underlined attributes if requested
- defaultPaint.setUnderlineText((currAttr & VDUBuffer.UNDERLINE) != 0);
+ // set underlined attributes if requested
+ defaultPaint.setUnderlineText((currAttr & VDUBuffer.UNDERLINE) != 0);
- // determine the amount of continuous characters with the same settings and print them all at once
- while(c + addr < buffer.width && buffer.charAttributes[buffer.windowBase + l][c + addr] == currAttr) {
- addr++;
- }
+ // determine the amount of continuous characters with the same settings and print them all at once
+ while(c + addr < buffer.width && buffer.charAttributes[buffer.windowBase + l][c + addr] == currAttr) {
+ addr++;
+ }
- // Save the current clip region
- canvas.save(Canvas.CLIP_SAVE_FLAG);
+ // Save the current clip region
+ canvas.save(Canvas.CLIP_SAVE_FLAG);
- // clear this dirty area with background color
- defaultPaint.setColor(bg);
- canvas.clipRect(c * charWidth, l * charHeight, (c + addr) * charWidth, (l + 1) * charHeight);
- canvas.drawPaint(defaultPaint);
+ // clear this dirty area with background color
+ defaultPaint.setColor(bg);
+ canvas.clipRect(c * charWidth, l * charHeight, (c + addr) * charWidth, (l + 1) * charHeight);
+ canvas.drawPaint(defaultPaint);
- // write the text string starting at 'c' for 'addr' number of characters
- defaultPaint.setColor(fg);
- if((currAttr & VDUBuffer.INVISIBLE) == 0)
- canvas.drawText(buffer.charArray[buffer.windowBase + l], c,
- addr, c * charWidth, (l * charHeight) - charTop,
- defaultPaint);
+ // write the text string starting at 'c' for 'addr' number of characters
+ defaultPaint.setColor(fg);
+ if((currAttr & VDUBuffer.INVISIBLE) == 0)
+ canvas.drawText(buffer.charArray[buffer.windowBase + l], c,
+ addr, c * charWidth, (l * charHeight) - charTop,
+ defaultPaint);
- // Restore the previous clip region
- canvas.restore();
+ // Restore the previous clip region
+ canvas.restore();
- // advance to the next text block with different characteristics
- c += addr - 1;
+ // advance to the next text block with different characteristics
+ c += addr - 1;
+ }
}
- }
- // reset entire-buffer flags
- buffer.update[0] = false;
+ // reset entire-buffer flags
+ buffer.update[0] = false;
+ }
fullRedraw = false;
}