Browse code

term/winconsole: Identify tty correctly, fix resize problem

This change fixes a bug where stdout/stderr handles are not identified
correctly.

Previously we used to set the window size to fixed size to fit the default
tty size on the host (80x24). Now the attach/exec commands can correctly
get the terminal size from windows.

We still do not `monitorTtySize()` correctly on windows and update the tty
size on the host-side, in order to fix that we'll provide a
platform-specific `monitorTtySize` implementation in the future.

Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>

Ahmet Alp Balkan authored on 2015/03/27 07:11:28
Showing 1 changed files
... ...
@@ -241,8 +241,6 @@ func StdStreams() (stdIn io.ReadCloser, stdOut io.Writer, stdErr io.Writer) {
241 241
 		}
242 242
 		handler.screenBufferInfo = screenBufferInfo
243 243
 
244
-		// Set the window size
245
-		SetWindowSize(stdoutHandle, DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_HEIGHT)
246 244
 		buffer = make([]CHAR_INFO, screenBufferInfo.MaximumWindowSize.X*screenBufferInfo.MaximumWindowSize.Y)
247 245
 
248 246
 		stdOut = &terminalWriter{
... ...
@@ -283,6 +281,12 @@ func GetHandleInfo(in interface{}) (uintptr, bool) {
283 283
 			isTerminalIn = IsTerminal(inFd)
284 284
 		}
285 285
 	}
286
+	if tr, ok := in.(*terminalWriter); ok {
287
+		if file, ok := tr.wrappedWriter.(*os.File); ok {
288
+			inFd = file.Fd()
289
+			isTerminalIn = IsTerminal(inFd)
290
+		}
291
+	}
286 292
 	return inFd, isTerminalIn
287 293
 }
288 294