Skip to content

Commit

Permalink
Load windows terminal sizes using `io.github.alexarchambault.windowsa…
Browse files Browse the repository at this point in the history
…nsi` (com-lihaoyi#4056)

~Currently appears to be blocked on my laptop by
com-lihaoyi#4055

Tested on my windows-arm surface book 7, seems to work great since
com-lihaoyi#4196 landed
  • Loading branch information
lihaoyi authored Jan 7, 2025
1 parent 42b3353 commit 5755423
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions runner/client/src/mill/runner/client/MillProcessLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static mill.main.client.OutFiles.*;

import io.github.alexarchambault.windowsansi.WindowsAnsi;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -218,9 +219,16 @@ static void writeTerminalDims(boolean tputExists, Path serverDir) throws Excepti
String str;

try {
if (!Util.hasConsole()) str = "0 0";
if (java.lang.System.console() == null) str = "0 0";
else {
if (!tputExists) {
if (isWin()) {

WindowsAnsi.Size size = WindowsAnsi.terminalSize();
int width = size.getWidth();
int height = size.getHeight();
str = width + " " + height;
mill.main.client.DebugLog.println(str);
} else if (!tputExists) {
// Hardcoded size of a quarter screen terminal on 13" windows laptop
str = "78 24";
} else {
Expand Down
1 change: 1 addition & 0 deletions runner/package.mill
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ object `package` extends RootModule with build.MillPublishScalaModule {
object client extends build.MillPublishJavaModule {
def buildInfoPackageName = "mill.runner.client"
def moduleDeps = Seq(build.main.client)
def ivyDeps = Agg(build.Deps.windowsAnsi)
}

def moduleDeps = Seq(
Expand Down

0 comments on commit 5755423

Please sign in to comment.