Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Support of clear screen #56

Closed
OllisGit opened this issue May 15, 2021 · 4 comments · Fixed by #57
Closed

Feature: Support of clear screen #56

OllisGit opened this issue May 15, 2021 · 4 comments · Fixed by #57
Assignees

Comments

@OllisGit
Copy link

First: Thx, a lot for this nice toolkit!!!!

Sometimes I want to start with a clear screen and the ANSI support this feature:
see: https://en.wikipedia.org/wiki/ANSI_escape_code (look for Erase in Display)

	StringBuilder clearScreenEscBuilder = new StringBuilder();
        char c = 27;
        char c2 = '[';
        clearScreenEscBuilder.append(c);
        clearScreenEscBuilder.append(c2);
        clearScreenEscBuilder.append("2");
        clearScreenEscBuilder.append("J");
		
        String clear = clearScreenEscBuilder.toString();
        String text = "�[34mMy Super Duper blue text on a clear screen�[0m";
        System.out.println(clear);
        System.out.println(text);

What do you think?

BR
Olli

@dialex dialex self-assigned this May 23, 2021
@dialex
Copy link
Owner

dialex commented May 23, 2021

Done 😉
It will be included in JColor 5.1.0. I'll try to push the new release now, otherwise check next Saturday.

The syntax is colorize(CLEAR_SCREEN()), so your example becomes:

String text = "�[34mMy Super Duper blue text on a clear screen�[0m";
System.out.println(colorize(CLEAR_TEXT()));
System.out.println(text);

Even though CLEAR_SCREEN() is an Ansi.Command and not an Ansi.Attribute I decided to maintain the colorized() syntax and avoid creating a new method.

Sidenote: I also gave H a try (source) but the results were incorrect. It actualy deleted the lines previously printed. The 2J simply pushes the previous lines up by adding new empty lines.

H output
H

2J output
2J

@dialex
Copy link
Owner

dialex commented May 23, 2021

Update: I'll release this feature on May 29, as I recently switched laptops and I don't have the right setup to release now

@dialex
Copy link
Owner

dialex commented May 29, 2021

Just deployed it to Maven Central. The new version (5.1.0) still doesn't appear listed there, as it usually takes a while (hours). Feel free to update your dependencies file for the new version and check if it can pull the latest version. If not, you'll have to wait :)

@OllisGit
Copy link
Author

Thx, a lot. Works as expected.

System.out.println( colorize( Command.CLEAR_SCREEN() ));

It is currently not listed in mvn, but this is not a big deal, because I am already using jitpack.io as an additional repo-proxy against github.

	<repositories>
		<!-- Used for private GitHub-Repositories. Needed for JColor -->
		<repository>
			<id>jitpack.io</id>
			<url>https://jitpack.io</url>
		</repository>
	</repositories>
...
		<dependency>
			<groupId>com.github.dialex</groupId>
			<artifactId>JColor</artifactId>
			<version>v5.1.0</version>
		</dependency>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants