From 856c8a2ad521064d69b2b50003c1df382d375013 Mon Sep 17 00:00:00 2001 From: Marcin Floryan Date: Sat, 3 Nov 2012 15:02:01 +0000 Subject: Download progress - CR character behaves as expected on Windows but not on other platforms. --- src/com/gitblit/build/Build.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/com/gitblit') diff --git a/src/com/gitblit/build/Build.java b/src/com/gitblit/build/Build.java index d5abc240..90cda130 100644 --- a/src/com/gitblit/build/Build.java +++ b/src/com/gitblit/build/Build.java @@ -48,6 +48,8 @@ import com.gitblit.utils.StringUtils; */ public class Build { + private static final String osName = System.getProperty("os.name"); + public interface DownloadListener { public void downloading(String name); } @@ -497,14 +499,17 @@ public class Build { } private static void updateProgress(float progress, String url) { - String anim = "=========="; + boolean isWindows = osName.contains("Windows"); + String anim = "=========="; int width = Math.round(anim.length() * progress); - System.out.print("\r["); + if (isWindows) System.out.print("\r"); + System.out.print("["); System.out.print(anim.substring(0, Math.min(width, anim.length()))); for (int i = 0; i < anim.length() - width; i++) { System.out.print(' '); } System.out.print("] " + url); + if (!isWindows) System.out.println(); } /** -- cgit v1.2.3