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

Text cursor invisible in editor mode - black on black background #180

Open
rmunn opened this issue Jan 26, 2024 · 1 comment
Open

Text cursor invisible in editor mode - black on black background #180

rmunn opened this issue Jan 26, 2024 · 1 comment

Comments

@rmunn
Copy link

rmunn commented Jan 26, 2024

if you type EDIT to get to the built-in editor, the text cursor is black no matter what the text foreground and background colors are set to. With the default white text on black background, that results in an invisible cursor. Changing the text background with SETTEXTCOLOR to something non-black worked, and allowed me to have a visible cursor in EDIT mode, but I'd rather find a permanent solution.

I've looked through the wxWidgets documentation and can't find any way to set the text cursor color (!), so for now in my own copy of UCBLogo I've applied the following patch to change the editor colors to black text on gray background:

--- TextEditor.cpp.orig	2024-01-26 10:05:33.421553166 +0700
+++ TextEditor.cpp	2024-01-26 10:05:40.518482194 +0700
@@ -46,31 +46,31 @@
 
 void TextEditor::SetFont(wxFont font){
 	this->font = font;
-	SetForegroundColour(TurtleCanvas::colors[wxTerminal::terminal->m_curFG]);
-	SetDefaultStyle(wxTextAttr(TurtleCanvas::colors[wxTerminal::terminal->m_curFG],
-				   TurtleCanvas::colors[wxTerminal::terminal->m_curBG], font));
+	SetForegroundColour(TurtleCanvas::colors[SPECIAL_COLORS+0]);
+	SetDefaultStyle(wxTextAttr(TurtleCanvas::colors[SPECIAL_COLORS+0],
+				   TurtleCanvas::colors[SPECIAL_COLORS+15], font));
 	if(this->IsShown()){
 		SetStyle(0,GetLastPosition(),
-			 wxTextAttr(TurtleCanvas::colors[wxTerminal::terminal->m_curFG],
-				    TurtleCanvas::colors[wxTerminal::terminal->m_curBG],font));
+			 wxTextAttr(TurtleCanvas::colors[SPECIAL_COLORS+0],
+				    TurtleCanvas::colors[SPECIAL_COLORS+15],font));
     SetBackgroundColour(
-		TurtleCanvas::colors[wxTerminal::terminal->m_curBG]);
+		TurtleCanvas::colors[SPECIAL_COLORS+15]);
 		Refresh();
 		Update();
 	}
 }
 
 void TextEditor::SetThisFont(wxCommandEvent& event) {
-	SetDefaultStyle(wxTextAttr(TurtleCanvas::colors[wxTerminal::terminal->m_curFG],
-				   TurtleCanvas::colors[wxTerminal::terminal->m_curBG], this->font));
+	SetDefaultStyle(wxTextAttr(TurtleCanvas::colors[SPECIAL_COLORS+0],
+				   TurtleCanvas::colors[SPECIAL_COLORS+15], this->font));
 	if(this->IsShown()){
 		wxTextPos lastPosition = GetLastPosition();
 
 		SetStyle(lastPosition > 0 ? lastPosition - 1 : 0, lastPosition,
-			 wxTextAttr(TurtleCanvas::colors[wxTerminal::terminal->m_curFG],
-				    TurtleCanvas::colors[wxTerminal::terminal->m_curBG],this->font));
+			 wxTextAttr(TurtleCanvas::colors[SPECIAL_COLORS+0],
+				    TurtleCanvas::colors[SPECIAL_COLORS+15],this->font));
 	    SetBackgroundColour(
-			TurtleCanvas::colors[wxTerminal::terminal->m_curBG]);
+			TurtleCanvas::colors[SPECIAL_COLORS+15]);
 		Refresh();
 		Update();
 		Refresh();

That works for what I need it for, but it's less than ideal as a general-purpose as it removes the possibility of customizing the colors in the editor via SETTEXTCOLOR. If anyone knows how to change the color of the blinking text cursor that wxWidgets draws, that would be a better solution to this issue. (Note that #11 would probably also have been fixed by this and #12 would have been unnecessary; the cursor was probably invisible because it was being drawn in black against a black background).

@rmunn
Copy link
Author

rmunn commented Jan 26, 2024

Probably caused by wxWidgets/wxWidgets#18722. My current system has wxWidgets 3.0.5 on it, where that bug exists. I see that wxWidgets/wxWidgets@2197f9d fixes the bug, at least for the wxGTK version (which is what I have), and that commit was incorporated into wxWidgets 3.1.4. So there are probably no code changes needed in UCBLogo, as long as a suitably recent version of wxWidgets is installed.

I'll leave this bug report open until I can confirm that wxWidgets 3.1.4 or later fixes the bug, then I'll close the issue once I'm certain that no change in UCBLogo will be necessary.

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

No branches or pull requests

1 participant