Page 1 of 1

Ctrl-S save shortcut

Posted: Wed Apr 20, 2016 12:04 am
by dicene
A large part of my recent motivation to compile the latest version of Mudlet was so I could add in support for CTRL+S to save scripts that I'm editing so I can simply tab back and forth between the main window for easy, mouse-free testing. Having gotten Mudlet compiled finally, I decided to dig deeper into the code to see what I'd have to do to add that support. Lo and behold, on line 348 of dlgTriggerEditor.cpp, I find:
//saveAction->setShortcut(tr("Ctrl+S"));
It was changed per commit 96bb8d2ed38df344403342439f2aa45d906748cc

I also see that a setShortcut call for Ctrl+F to be linked with the search feature has been disabled via a different commit, but I don't really care about that particular function enough to want to enable it.

Edit 1: Welp, uncommented that line and it seems to be working just fine. In fact, went ahead and inserted
Code: [show] | [select all] lua
profileSaveAction->setShortcut(tr("Ctrl+Shift+S"));
at line 371 and now I can save the profile with ctrl+shift+s while in the code editor. =D

Edit 2: Started messing around with TTextEdit.cpp trying to get Cmud style full-line highlighting when you click on the timestamp besides a line. Getting it to work with just single clicks was actually really easy, but getting it to work when dragging across multiple lines proving to be a bit tougher. It works dragging upwards through lines currently, but I'm having a hard time figuring out how to change
Code: [show] | [select all] lua
void TTextEdit::mouseMoveEvent( QMouseEvent * event )
to suit me. Will post again if I manage to get it working 100% at some point.

Re: Ctrl-S save shortcut

Posted: Thu Apr 21, 2016 8:20 pm
by SlySven
Check it still works as expected if there is MORE than one profile active - IIRC the short-cut system is bound to the menu-bar of the main application window (and only works if that - the menu-bar - is VISIBLE) and if there is more than one profile open/active then the short-cut gets applied to the currently active (selected tab) in the main application window - either of these may not be what you are expecting to happen!

BTW Guess you haven't got a previously bugged 3.0.0-preview version that fatally Seg.Faults if you click on the timestamp... ;)

Re: Ctrl-S save shortcut

Posted: Sat Apr 23, 2016 4:36 pm
by dicene
Hehe. I looked over the beautiful little two-line code additions that stopped those crashes. Very thankful those got implemented. =D

Re: multiple profiles: I opened up a new Mudlet window and loaded two empty, different profiles, opened up the script editor for both, and added a simple script that did echo("!") so that every time their scripts were saved, I could see that printed to their main output. I moved from one script editor to the other and used the ctrl+s shortcut, and Mudlet properly respected which editing window I had open and only saved that script when I did it. I will mention that the shortcut only works while the window is in focus, but that is pretty much the way I wanted it to work, and that apparently is keeping it from having issues when I have multiple profiles open.

I can't really imagine any other bugs popping out from this, so I'd suggest considering reenabling it during the next official release. If you want a commit for it, I can try and learn how to git(hub) and stop being so scrubby and post it myself, just lemme know.

Re: Ctrl-S save shortcut

Posted: Sat Apr 23, 2016 7:53 pm
by SlySven
One issue that we may have going forward is touched at indirectly in the use of the tr(...) around the specification of the short-cut. Future care will have to be taken to make sure that the short-cut makes sense when it is translated into different languages, but that is not an issue for the moment (mayhaps Mudlet 4.0?) - but there are a whole issue of other things to sort out for that... :D