 So gdb, the GNU debugger added a new feature where in the tui mode, you can scroll around using the mouse wheel. However, this feature broke selecting text, like if I want to set a break point on something, I can just double click it and then type out break on that thing. Or if there's some code I want to rerun or some expression I want to evaluate manually, I can't just do that by selecting and then pasting it. So today we're going to figure out what's wrong and then fix it. So first things first is we need to build the code from source, and make sure that we have a development version that also has the bug. I know I have the code checked out here. Let's make sure it's up to date. Okay, now it's up to date. Now we need to look at the instructions on how to build it. So let's look at the read me dot slash configure and make I don't want all the tools. I just want GB. Well, let's do it anyway, I guess. Building GB requires GMP and workflow. Live GMP dev lib MP of R dev. Maybe that'll work. Try again. Hey, seem to work. compile. This will take forever. Oh, the build failed. Why did it fail? There must be an error message somewhere. Warning, make info is missing apps install make info. Where's make info? Tech info. That's it. Try again. So while we wait for this to build, let's figure out what code might be relevant. So I think that this stuff is probably using end curses for the two e the text user interface. So I want like end curses text mode. No, not text mouse mode. has mouse get mouse mouse mask. So it's probably related to get mouse, right? Or has mouse. So let's wait, did it finish? Okay, maybe it finished. Hey, there's no colors, but the mouse thing is problems and addicts still. Okay, so we were able to build a development version. So let's look for them has mouse function. Nothing. Get mouse. Hey, get mouse. Can we dispatch mouse event? So who's calling this? If the character is key mouse. So this is handling the mouse events. But what turns them on in the first place? Asmas to make mouse events visible use mouse mask. So I guess I want mouse mask. So there's all mouse events and zero and zero. So maybe first text selection, I can change this to just button four and five. Let's see what events they use. So the events, they look at one, two and three clicks. That's the problem. And four and five pressed. Let's see what happens if I just do four and five pressed. I should give us a scrolling but not the click behavior. Maybe scrolling works. But I still can't click. So maybe I just need to turn this off. Scrolling still work. Oh, and now I can click. So scrolling was still working. That's interesting. Maybe there's another mechanism they use for scrolling. Maybe it's nothing to do with this scrolling code. So let's turn this off. Try that. Yeah, that's codes not active. So something else is doing the scrolling. Maybe there's a separate scroll thing. Okay. Maybe I was wrong originally about the scroll feature. Anyway, the setting the mask mask to zero seems to fix it. So what I'm thinking is because there's no way to keep like obviously there's no way to keep this behavior while also keeping the dark terminal behavior, I think we need to just turn off mouse mask. But that needs to be a user setting. So we need to research how to make a user setting in GDP. And I suspect there's no user setting already. There's a secret I looked into this yesterday. And I'm only now recording the video. Some of this already knew. But so let's try to make a setting. So this command shows the settings. So let's find a name for maybe unique setting like circular trace buffer. Add set show bully and combed. I guess we want one of these on set show. Okay, here's the two options. Let's add what is class. No class. Figure what this means. Maybe there's docs for that. H file. There we go. Class to E. Oh, I see what's going on. I think I'm not sure anyway. So debug two is Boolean to H pool enable mouse to enable mouse. True actually is a default. So mine is to enable mouse truly supports mouse clicks. I don't know. So what is this stuff down here? Show to debug null. Oh, you can put custom code there. So that's like a callback, huh? I guess we need a show. That's kind of dumb. Why doesn't it just do it for me? Show to mouse events like that name better. I need new formatting. This doesn't look aligned. Actually, does Vim align it? Yes, it does. Good. Okay, and then here show to E mouse events. Well, let's see if it shows up in the settings list. Oh, I broke something. So it's saying to reset list is not declared. Because it's stuffed into this guy. So I guess I got to put my code in here. Not where I put it. Now we should be able to show to E and it should appear mouse events. It's on help show to E show mouse events and to E mode. I'm missing a period. So it's currently on. And I should be able to set to E mouse events off and show and it's off now doesn't do anything yet. But cool. So let's commit our work. Oh my gosh. All these things. Let's commit our work whip. And now I have to wire the setting up with actual behaviors. So that's we lost it. mouse mask. This guy. So we need to say if to enable mouse. So default behavior broken. I set to E mouse events off. I can select things now. Yay. Now when I did that I went out of the mode. So if I set it back to on and go back in. Now if I turn it off again. Wow that worked. I did not expect it to magic the work. Hey, I guess we're done. I thought we would have to do some hook thing to change the mode if it's already visible. But I guess not. So let's look at the contributor guide. Let's read the read me. Contribute. Reporting bugs. See that. Oh, there's a GDB read me. Reporting bugs. Graphical interface. Writing code. Contribute. Okay, there's a file called contribute. For information see here. If you write a change, we encourage you distribute the change yourself. We also want to submit your change so you can be considered for inclusion. That's what I want. Certainly requirements. Check the contribution checklist. Okay, describe the rationale for my patch. Okay, explain how you test the patch. Okay. Okay, what's the title? Do patches look like this? Add set to mouse off to restore mouse selection. Okay, there's my message. Now what? Documentation. If your patch adds a new command should be added in the manual and mention in the news file. Oh, I need to do this. Update the docs. So we need to, I guess, look at an existing option such as to occur position and see where the docs are. There's a news file. So I need to put that there. But I want to do the doc first mouse events. I guess. So that's a doc. So let's add that to our commit. And we need the news. Oh, where other things documented, such as compact source new commands. So they just listed as a new command. Word ramping. Fim get it right. Okay, updated the news. Testing. I'm lazy. Public format changes. Sure. Submitting patches, send the patch to this. Get format patch. I think that's how you do it. And sent sent. That gets sent to a mailing list, right? So I can look at the archives to see my message. I don't know when it'll appear here. What is it you did? I fixed the bug or added a feature depending your perspective to quick Lynn, not quick Lynn. Hey, there's my email, which of course, this mailing list doesn't pretty colorize the patch. So so let's recap. First, we identified the issue. Then we built GDB from source so that we could reproduce the issue and also so that we could make code changes. Then we searched the code base for relevant code and hard coded a fix to keep the old behavior as an option. We added a configuration setting copy, paste and code from existing settings. Then we looked at the contributor guide, which told us what to include in our commit message and where to put user facing documentation. Finally, we sent off an email with the patch as an attachment. The whole process took about 45 minutes from downloading the code to sending the email off. The GDB maintainers eventually applied my email. They seem receptive and suggested some documentation improvements. Hopefully my patch ends up in the next version of GDB. I hope this video showed you how easy it is to contribute to open source, even for dinosaur projects, which use email instead of GitHub.