nvim - deactivating mouse - linux

can you help me? I Want to deactivate the mouse in nvim. It should neither scroll, nor change the cursor position.
I added the following lines to my init.lua, to disable scrolling by mouse:
for _, amplitude in ipairs({ "", "S-", "C" }) do
for _, direction in ipairs({ "Up", "Down", "Left", "Right" }) do
for _, modus in ipairs({ "", "i" }) do
vim.keymap.set(modus, "<" .. amplitude .. "ScrollWheel" .. direction .. ">", "<Nop>", { })
end
end
end
This works, and scrolling is disabled. However, I can still change the curser position by point and click. To disable this, I also added the following line:
vim.opt.mouse = ""
Now, I can't change the curser by point and click, but scrolling is active again. I don't understand why? Is there a way to deactivate both?

Related

insert GlyphProperty.null in shouldGenerateGlyphs causes cursor misplacement problem

I am hiding the character * by inserting GlyphProperty.null then calling setGlyphs(_:properties:characterIndexes:font:forGlyphRange:) inside layoutManager(_:shouldGenerateGlyphs:properties:characterIndexes:font:forGlyphRange:) as described in the answer in https://stackoverflow.com/a/57697139/9568961, it works but after a certain sequence of text editing, the cursor starts to misplace, as shown in the gif https://github.com/dzAtZJU/Demos/blob/master/cursor_misplace.GIF?raw=true
GIF Description: When the second line becomes qq, I try to move the cursor to the end of first line, but it move directly to the beginning. I then try to delete characters, then the cursor move to the end correctly.
The sample project is here https://github.com/dzAtZJU/HideText.
Is it a bug? Have anyone run into this? How can I work around this?
This is a year-old question, but for anyone struggling with the same problem, here's a solution.
My Markdown-like parser knows the ranges for both the line on which the cursor is now, and where it was previously. I'm calling hideAndShowMarkup whenever text view selection changes.
You need to invalidate current glyphs for both of the ranges, and then redraw them synchronously before updating insertion point. The most crucial step is invalidating layout for the range where you want to show Markdown symbols. Without that, your caret gets drawn into the wrong position.
Code is in Objective C, but should be easy to implement in Swift, too.
-(void)hideAndShowMarkup {
// Just for reference
Line* line = currentLine;
Line* prevLine = previouslySelectedLine;
[self.layoutManager invalidateGlyphsForCharacterRange:line.range changeInLength:0 actualCharacterRange:nil];
[self.layoutManager invalidateGlyphsForCharacterRange:prevLine.range changeInLength:0 actualCharacterRange:nil];
[self.layoutManager invalidateLayoutForCharacterRange:line.range actualCharacterRange:nil];
if (NSGraphicsContext.currentContext) {
[self.layoutManager drawGlyphsForGlyphRange:line.range atPoint:self.frame.origin];
[self.layoutManager drawGlyphsForGlyphRange:prevLine.range atPoint:self.frame.origin];
}
[self updateInsertionPointStateAndRestartTimer:NO];
}

ahk click down mouse button while holding down a key on keyboard

I want to move the mouse with one hand while with the other making the button clicks with the keyboard.
The difficult part was to instruct AutoHotKey to hold down the mouse button while holding down the key on the keyboard. So you be able to click and drag.
It makes the clicks with the 1, 2 and 3 keys at the keyboard, in inverse order (left click with the 3, as preserving left click with the index finger but of the other hand, trying to mirror the workings inside the brains hemisphere, or something)
This script is activated while ScrollLock is ON (finally some good use for that beautiful and neglected key, activating all sorts of keyboard shortcuts for AutoHotKey)
#NoTrayIcon
if (GetKeyState("ScrollLock", "T")) ; check state for icon
{
Menu, Tray, Icon
return
}
else
{
Menu, Tray, NoIcon
return
}
ScrollLock:: ; From state 0 to state 1 (Activated)
Send, {ScrollLock}
Menu, Tray, Icon
SoundBeep, 261.43, 150 ; low tone
SoundBeep, 329.63, 150 ; hight tone
return
#If GetKeyState("ScrollLock", "T") ; State 1 (Activated)
3::
While GetKeyState("3", "P")
{
Click, Left, Down
KeyWait 3
Click, Left, Up
}
Return
2::
While GetKeyState("2", "P")
{
Click, Middle, Down
KeyWait 2
Click, Middle, Up
}
Return
1::
While GetKeyState("1", "P")
{
Click, Right, Down
KeyWait 1
Click, Right, Up
}
Return
ScrollLock:: ; From State 1 to State 0 (Deactivated)
Send, {ScrollLock}
Menu, Tray, NoIcon
SoundBeep, 329.63, 150 ; hight tone
SoundBeep, 261.43, 150 ; low tone
return
^SPACE:: ; Always on Top Functionality
Winset, Alwaysontop, , A
return
#If
Script: Keyboard-Clicks.ahk
It gets activated with the ScrollLock key.
It shows the a tray icon when activated.
It hides the icon when is deactivate it with ScrollLock key again.
Key combination Ctrl+Space for AlwaysOnTop the currently active window.
It makes a distinctive sound beep for activated and de-activated state.
Compiled with an icon from Font Awesome of a hand.
Font-Awesome-left-hand-paper Icon PNG with Transparency
https://i.imgur.com/6tvfVNS.png

Get and set correct window position with node.js

In the close event I persist the window position as follows:
localStorage.lastlayout = JSON.stringify({
"left": win.x,
"top": win.y,
"width": win.width,
"height": win.height
});
On start, I restore it with:
data = JSON.parse(localStorage.lastlayout);
win.moveTo(data.left, data.top);
win.resizeTo(data.width, data.height);
The problem is the position is off. As far as I can tell, I get the inner position. When setting I set the outer position. The windowing title and borders only accounted for when setting.
As this is cross-platform code I cannot test it on all platforms (yet) and I don't know if it is possible to get the metrics of the windowing engine so that I can correct it programmatically (think about the user changing the DPI or theme on Windows).
Is there a way to compensate for this?
Ok, I've nailed it. I detect the offsets in respect to a known position (0, 0) and then detract it from the desired position. It's not perfect but it works:
win.resizeTo(128, 128);
win.moveTo(0, 0);
log("dbg", "win", "detected metrics: " + win.x + ", " + win.y);
win.moveTo(data.left - win.x, data.top - win.y);
win.resizeTo(data.width, data.height);
The initial resize is necessary for some reason. It looks like the title and borders are not drawn at all on some platforms if the window is not large enough. Next I move it to the origin. The win.x and win.y contain the offsets at this point. The second moveTo() uses the corrected coordinates and finally I resize the window to the actually desired size.

Snap SVG - Animating a Path in the opposite direction

I am working on a path animation, but am stuck at how to accomplish it in reverse.
http://jsfiddle.net/t1yu3mcn/1/
Currently, the red path starts at full length, and over time becomes shorter and shorter from the right direction. I want to accomplish the same animation but where the path gets shorter starting from the left direction. (starts disappearing from the left rectangle, and ends disappearing at the right rectangle).
I have tried altering the following snippet inside .animate:
'stroke-dasharray': val + ' ' + (pathCoverLength - val)
But changing this around to different values never results in the correct effect.
Does anybody know an easy way of accomplishing this?
One way is to juggle the dashOffset point further...
jsfiddle
pathCover.attr({ strokeDasharray: pathCoverLength + ' ' + pathCoverLength })
Snap.animate(pathCoverLength*2, pathCoverLength, function(val) {
pathCover.attr({
strokeDashoffset: val });
}, 7000, mina.ease);

JavaFX: how to set correct tooltip position?

I have a TextField for which I want a Tooltip to be shown under some circumstances.
After performing checks I run the followig code:
textFieldUsername.setTooltip(new Tooltip("Enter username!"));
textFieldUsername.getTooltip().setAutoHide(true);
textFieldUsername.getTooltip().show(textFieldUsername, 1, 1);
So when somebody tries to login with empty username he gets a prompting Tooltip over the "username" TextField.
But when it comes to action, the Tooltip pops up in the top left corner of the screen.
Should I calculate coords of my scene, then add my TextField coords to them, or there is a way to set these 1, 1 arguments from the call of show() to be relative to the TextField position?
I think the coordinates are always relative to the screen. To calculate component coordinates you need to incorporate scene and window coordinates.
Point2D p = label.localToScene(0.0, 0.0);
label.getTooltip().show(label,
p.getX() + label.getScene().getX() + label.getScene().getWindow().getX(),
p.getY() + label.getScene().getY() + label.getScene().getWindow().getY());

Resources