Created
April 16, 2012 05:39
-
-
Save huynhjl/2396522 to your computer and use it in GitHub Desktop.
Does cursor wrap when char is printed in last col?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Determine terminal width (for instance with stty -a) then pass that width as | |
* the first argument. If the cursor does not move to the next line after | |
* printing the 'a' characters then the terminal does not automatically wrap | |
* when the character is printed in the last column. | |
* For instance in Ubuntu, the cursor will not be visible. | |
*/ | |
public class WrapInLastColumn { | |
public static void main(String[] args) { | |
int width = 80; | |
try { | |
width = Integer.parseInt(args[0]); | |
System.out.printf("printing %d 'a' chars, then sleep 5s.%n", width); | |
System.out.printf("Check where cursor is...%n"); | |
for (int i = 0; i < width; i++) { | |
System.out.print('a'); | |
} | |
Thread.sleep(5000); | |
System.out.println(); | |
} catch (Exception e) { | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment