Change mintty keyboard shortcuts - msys2

mintty 2.8.5 for MSYS2 uses Shift+Insert for pasting. But on my laptop the Insert btn is unhappily combined with Delete key, i.e., to actually paste in mintty I need to press Shift+Fn+Delete, which is annoying.
Is it possible to bind the mintty paste op to Shift+Delete?

The only way I can think of is with a patch akin to
diff --git a/src/wininput.c b/src/wininput.c
index 20f2f3e..0f2958c 100644
--- a/src/wininput.c
+++ b/src/wininput.c
## -2033,7 +2033,8 ## win_key_down(WPARAM wp, LPARAM lp)
goto skip_shortcuts;
// Copy&paste
- if (cfg.clip_shortcuts && key == VK_INSERT && mods && !alt) {
+ if (cfg.clip_shortcuts && (key == VK_INSERT || key == VK_DELETE)
+ && mods && !alt) {
if (ctrl)
term_copy();
if (shift)
I've tested it with the rev 0e65eec39 of https://github.com/mintty/mintty

Related

Detect if a Tcl script is run in a background process

I'm looking for a preferably cross-platform way to detect from within a Tcl script if the interpreter is running in a foreground or in a background process.
I've seen how to do it via ps (or /proc/$$/stat on Linux); is there a better way or do I have to hack something around that approach? I already have a utility library written in C so exposing the lowlevel API that ps also uses so I don't have to parse process output (or special file content) would be fine.
There's no truly cross-platform notion of foreground, but the main platforms do have ways of doing it according to the notion they have of foreground.
Linux, macOS, and other Unix:
For determining if a process is foreground or not, you need to check if its process group ID is the terminal's controlling process group ID. For Tcl, you'd be looking to surface the getpgrp() and tcgetpgrp() system calls (both POSIX). Tcl has no built-in exposure of either, so you're talking either a compiled extension (may I recommend Critcl for this?) or calling an external program like ps. Fortunately, if you use the latter (a reasonable option if this is just an occasional operation) you can typically condition the output so that you get just the information you want and need to do next to no parsing.
# Tested on macOS, but may work on other platforms
proc isForeground {{pid 0}} {
try {
lassign [exec ps -p [expr {$pid ? $pid : [pid]}] -o "pgid=,tpgid="] pgid tpgid
} on error {} {
return -code error "no such process"
}
# If tpgid is zero, the process is a daemon of some kind
expr {$pgid == $tpgid && $tpgid != 0}
}
Windows
There's code to do it, and the required calls are supported by the TWAPI extension so you don't need to make your own. (WARNING! I've not tested this!)
package require twapi_ui
proc isForeground {{pid 0}} {
set forground_pid [get_window_thread [get_foreground_window]]
return [expr {($pid ? $pid : [pid]) == $foreground_pid}]
}
Thanks to Donal I came up with the implementation below that should work on all POSIX Unix variants:
/*
processIsForeground
synopsis: processIsForeground
Returns true if the process is running in the foreground or false
if in the background.
*/
int IsProcessForegroundCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
{
/* Check the arg count */
if (objc != 1) {
Tcl_WrongNumArgs(interp, 1, objv, NULL);
return TCL_ERROR;
}
int fd;
errno = 0;
if ((fd = open("/dev/tty", O_RDONLY)) != -1) {
const pid_t pgrp = getpgrp();
const pid_t tcpgrp = tcgetpgrp(fd);
if (pgrp != -1 && tcpgrp != -1) {
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(pgrp == tcpgrp));
close(fd);
return TCL_OK;
}
close(fd);
}
Tcl_SetErrno(errno);
Tcl_ResetResult(interp);
Tcl_AppendResult(interp, "processIsForeground: ", (char *)Tcl_PosixError(interp), NULL);
return TCL_ERROR;
}
int Pextlib_Init(Tcl_Interp *interp)
{
if (Tcl_InitStubs(interp, "8.4", 0) == NULL)
return TCL_ERROR;
// SNIP
Tcl_CreateObjCommand(interp, "processIsForeground", IsProcessForegroundCmd, NULL, NULL);
if (Tcl_PkgProvide(interp, "Pextlib", "1.0") != TCL_OK)
return TCL_ERROR;
return TCL_OK;
}

How do I stop KDE from changing the alt-tab order of minimized windows?

I'm on KDE Plasma 5.16.5 on Manjaro. When I use my keyboard shortcut to minimize a KDE window, I would like to be able to restore it by just pressing alt-tab, similar to when I alt-tab without minimizing.
What is a reasonable way to achieve this?
The primary use case I have for this is chat apps. People are often talking to me, but I'm also working. I want to "minimize" the chat app so that I don't see it, but I want to be able to alt-tab back to it without having to search for it at the end of the list. I can sometimes use Alt-Space, search for it, and find it in the windows, but this doesn't always seem to work (and it's not as embedded in my muscle memory).
I'm fairly open to alternative solutions. An alternative alt-tab interface, more similar to Mac/Windows (centered icons) would also be fine.
Here is the needed patch to Kwin to achieve this, build your version then use /usr/local/bin/kwin_x11 --replace to test it.
From 47d6ab59eb8914ddb0857382f2d42dff8bb11402 Mon Sep 17 00:00:00 2001
From: intika <intika#librefox.org>
Date: Tue, 5 May 2020 09:40:08 +0200
Subject: [PATCH] Patch behavior of ctrl+tab to act like mac and windows
---
focuschain.cpp | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/focuschain.cpp b/focuschain.cpp
index 229314968..b3912fba7 100644
--- a/focuschain.cpp
+++ b/focuschain.cpp
## -238,17 +238,17 ## AbstractClient *FocusChain::nextForDesktop(AbstractClient *reference, uint deskt
void FocusChain::makeFirstInChain(AbstractClient *client, Chain &chain)
{
chain.removeAll(client);
- if (client->isMinimized()) { // add it before the first minimized ...
- for (int i = chain.count()-1; i >= 0; --i) {
- if (chain.at(i)->isMinimized()) {
- chain.insert(i+1, client);
- return;
- }
- }
- chain.prepend(client); // ... or at end of chain
- } else {
+// if (client->isMinimized()) { // add it before the first minimized ...
+// for (int i = chain.count()-1; i >= 0; --i) {
+// if (chain.at(i)->isMinimized()) {
+// chain.insert(i+1, client);
+// return;
+// }
+// }
+// chain.prepend(client); // ... or at end of chain
+// } else {
chain.append(client);
- }
+// }
}
void FocusChain::makeLastInChain(AbstractClient *client, Chain &chain)

in icecream scheduler log, what does "<host> not eligible " mean?

While diagnosing slow build times using icecream. I encounted several instances of the following message in the icecc-scheduler logs:
<hostname> not eligible
What is this trying to communicate to me?
This could stem from a few scenarios and they are documented in the source code here
bool CompileServer::is_eligible(const Job *job)
{
bool jobs_okay = int(m_jobList.size()) < m_maxJobs;
bool load_okay = m_load < 1000;
bool version_okay = job->minimalHostVersion() <= protocol;
return jobs_okay
&& (m_chrootPossible || job->submitter() == this)
&& load_okay
&& version_okay
&& m_acceptingInConnection
&& can_install(job).size()
&& this->check_remote(job);
}
I'd check to make sure that each host is:
iceccd is run as root
each host has the same version of icecc installed. Verify with /usr/bin/icecc --version
plenty of free space left
maximum number of jobs has not been exceeded

Move selection sequentially in NSCollectionView

By default selection in NSCollectionView get moved by arrow keys within one row (or column).
How to make selection move sequentially, like items arranged by index?
Screenshot from developer.apple.com
I have asked same question to Apple Developer Technical Support, after checked they said "Our engineers have reviewed your request and have determined that this would be best handled as a bug report.". I submitted bug report to Apple's radar. So far no response.
I decided to implement my own solution. Subclass your NSCollectionView and override keyDown event.
Swift 4
override func keyDown(with event: NSEvent) {
if event.modifierFlags.rawValue == 10617090 {
return
}
if event.isARepeat == true && event.keyCode != 123 && event.keyCode != 124 && event.keyCode != 125 && event.keyCode != 126 {
return
}
if event.keyCode == 123 || event.keyCode == 124 || event.keyCode == 125 || event.keyCode == 126 {
for index in self.selectionIndexes {
if event.keyCode == 124 && index < YOUR_DATASOURCE_ARRAY.count - 1 {
self.deselectItems(at: [NSIndexPath(forItem: index, inSection: 0) as IndexPath])
self.selectItems(at: [NSIndexPath(forItem: index + 1, inSection: 0) as IndexPath], scrollPosition: NSCollectionView.ScrollPosition.nearestHorizontalEdge)
return
}
if event.keyCode == 123 && index > 0 {
self.deselectItems(at: [NSIndexPath(forItem: index, inSection: 0) as IndexPath])
self.selectItems(at: [NSIndexPath(forItem: index - 1, inSection: 0) as IndexPath], scrollPosition: NSCollectionView.ScrollPosition.nearestHorizontalEdge)
return
}
}
}
super.keyDown(with: event)
}
This interrupts left and right arrow key inputs and move selection to previous/next cell. Since
"Allows Multiple Selection" has to be NO. Also disable modifier keys as like CMD or Control.
If you keep pressing right arrow, when selection arrives to last cell at right hand it jump one row down and keep moving or vice versa for left arrow.
Hope it helps.

intellij wrap and sign

What's the setting I need to change in my IntelliJ (Android Studio) IDE to make formatting change this line:
return Objects.equal(this.city, other.city) && Objects.equal(this.state, other.state) && Objects.equal(this.country, other.country) && Objects.equal(this.location, other.location) && Objects.equal(this.streetAddress1, other.streetAddress1) && Objects.equal(this.streetAddress2, other.streetAddress2) && Objects.equal(this.postalCode, other.postalCode);
to look like this:
return Objects.equal(this.city, other.city) &&
Objects.equal(this.state, other.state) &&
Objects.equal(this.country, other.country) &&
Objects.equal(this.location, other.location) &&
Objects.equal(this.streetAddress1, other.streetAddress1) &&
Objects.equal(this.streetAddress2, other.streetAddress2) &&
Objects.equal(this.postalCode, other.postalCode);
It's possible:
Go to Settings -> Code Style -> Java -> Wrapping and Braces [tab] ->
Binary Expressions [tree node]
Set Binary Expressions to Chop down if long
Check the Align when multiline
I have also had success on teams using mixed IDE's with JIndent. Although commercial its more powerful and is IDE and build agnostic.