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

Fixes #219. Adds Underline and Blink #1275

Closed
wants to merge 7 commits into from

Conversation

jmperricone
Copy link
Contributor

UNDERLINE

@jmperricone jmperricone marked this pull request as draft April 30, 2021 01:07
@jmperricone
Copy link
Contributor Author

jmperricone commented Apr 30, 2021

It works with WindowsDriver, CursesDriver and NetDriver(windows).

The only thing that seems off to me is that I did not make Attribute.Value contain this value as well.

If someone is using this value assuming it only have color, it would be very bad.

NetDriver sets the biggest number.

value = ((((int) f) & 0xffff) << 16) | (((int) b) & 0xffff)

with ConsoleColor.White = 15

value == 0xF000F

using something like 0x100000 for underline would be possible if I'm not wrong.

Tell me what you think. I set this as a draft.

@BDisp
Copy link
Collaborator

BDisp commented Apr 30, 2021

Good work. Any day we will have the #48 RGB working :-)
You can play with that limit values, you'll see very interesting. You can achieve a greater colors values. Only it'll need to change the default for each of ColorScheme. Otherwise you'll have identical colors.
It's possible to underline only words too?

@jmperricone
Copy link
Contributor Author

jmperricone commented Apr 30, 2021

Yes you, can underline words, like you change the color of a word.

I just realized that it will only work for windows, when using the netdriver.

@BDisp
Copy link
Collaborator

BDisp commented Apr 30, 2021

I am pleased for my CSI (Code Sequence Introducer) implementation on the NetDriver. Too bad it's too slow on Windows.

@jmperricone
Copy link
Contributor Author

I just realized that it will only work for windows, when using the netdriver. (@jmperricone)

Now that I read this, it seems to me that it is not clear.

It works with CursesDriver and the WindowsDriver.

What I meant is that with the NetDriver, it only works on Windows. This is what I did:

void SetUnderline (bool state)
{
	redrawUnderline = state;
	if (IsWinPlatform == true) {
		var OutputHandle = NetWinVTConsole.GetStdHandle (NetWinVTConsole.STD_OUTPUT_HANDLE);
		var success = NetWinVTConsole.GetConsoleScreenBufferInfo (OutputHandle, out var csbi);
		if (success) {
			if (state == true) {
				csbi.wAttributes |= 0x8000;
			} else {
				csbi.wAttributes &= 0x7FFF;
			}
			NetWinVTConsole.SetConsoleTextAttribute (OutputHandle, csbi.wAttributes);
		}
	}
}

@BDisp
Copy link
Collaborator

BDisp commented Nov 20, 2021

What I meant is that with the NetDriver, it only works on Windows.

You don't need to use Windows API to work on Windows. The only reason I use Windows API was because the System.Console don't recognize escape sequences on Windows and I needed to use ENABLE_VIRTUAL_TERMINAL_PROCESSING for that. To do that, you need to use escape sequences "\x1B[4m" to underline and "\x1B[24m" to reset, maintaining any colors set, both valid to Windows and Linux.

@BDisp
Copy link
Collaborator

BDisp commented Nov 20, 2021

But is better to add the underline bitwise to the contents attribute than increase the contents length to save the underline.

@BDisp
Copy link
Collaborator

BDisp commented Nov 21, 2021

@jmperricone, when you have the time please check my PR jmperricone#1, please. Thanks.

@jmperricone
Copy link
Contributor Author

Hi, thanks for the pull #1 @BDisp

About the bitwise underline, I thought about that:

If someone is using this value assuming it only have color, it would be very bad.
#1275 (comment)

Because Driver.GetAttribute() is

public override Attribute GetAttribute ()
{
	return currentAttribute;
}
...
public static implicit operator Attribute (int v) => new Attribute (v);
...

Then Attribute.Value contains that

If that is not a problem, is ok!

@BDisp
Copy link
Collaborator

BDisp commented Nov 21, 2021

If that is not a problem, is ok!

It's okay because if Attribute.Underline is true it's possible to extract from the value.

@jmperricone
Copy link
Contributor Author

Should be that added to the Attribute.Value Property Get(). For example if someone have code like:

if (attr.Value > 100) {
   ...
}

Having Underline set, will always return true.

@BDisp
Copy link
Collaborator

BDisp commented Nov 21, 2021

Having Underline set, will always return true.

Is true, but the user may check if Underline property is true and so the value isn't only colors, taking the desired action. But, normally, the user may take the colors by checking in the Background and Foreground colors.

@tig tig added the v2 For discussions, issues, etc... relavant for v2 label Feb 24, 2023
@tig
Copy link
Collaborator

tig commented Mar 3, 2023

We need to create an Issue for this set to point to the v2 Project (https://github.com/orgs/gui-cs/projects/1) and retarget this PR at the v2_develop branch.

@tig tig changed the title Feature underline Fixes #219. Adds Underline and Blink Apr 16, 2023
@tig
Copy link
Collaborator

tig commented Jul 25, 2023

This work should be merged into #2612. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2 For discussions, issues, etc... relavant for v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants