Skip to content

Instantly share code, notes, and snippets.

@huynhjl
Created April 16, 2012 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huynhjl/2396522 to your computer and use it in GitHub Desktop.
Save huynhjl/2396522 to your computer and use it in GitHub Desktop.
Does cursor wrap when char is printed in last col?
/**
* 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