cannot select text in VTE using keyboard - gtk

I'm writing my own terminal application in C using the VTE library. Everything works great except I cannot select text with the keyboard. For example if I have just typed something, in most terminals you can hold down the shift key and select the previous text with the left arrow key, then you can paste it wherever you want. In VTE, all that happens is you get a D in the current cursor position. I can obviously block the printing of D in the terminal by returning TRUE from the keypress (which I have done), but I still cannot select the text.
I thought I might be able to do it manually starting with vte_terminal_get_cursor_position(), but there is no method to select a block of text (that I could find) in VTE once I have the boundaries for the selection.
I've looked at other VTE based projects such as tinyterm, and evilvte, but they just print the D in the terminal as well when that key combination is pressed.
So is there any way to select text in VTE using the keyboard? Thanks.
Correction:
It turns out that very few if any terminals allow you to select text with the keyboard. Not sure how that got into my head. Anyway, I still think it would be a handy capability, so the question stands. Any ideas would be greatly appreciated.

Related

How to remap Tab key to two dots/period key presses

I want to map two dot/period key presses to Tab key in AutoHotkey script. I tried to map similarly as its shown for remapping semicolon key - on AutoHotkey forums, but it doesn't work. I tried following:
1. `..`::Tab
2. ..::Tab
AutoHotkey gives an error
.
I tried searching on AutoHotkey Remap docs, but couldn't figure it out. The period key is the one with the greater than mark and not the number keypad period key. See this: Dot/period key
Addition info/context in response to reply by user 0x464e:
Basically, I am trying to expand Emmet style abbreviations in devtools style sub-panel since the chrome devtools team wont implement it.
I am not a fast typist, so it's a pain to type complete property names. For example, if I want to type margin-top, (see the image), Chrome autocomplete brings up margin, margin-block margin-block-end etc.
Now, for margin-top, you need to at least type margin-t to get the autocomplete to show that property.
This is the case for many very common CSS properties like margins, paddings, etc., so autocomplete isn't great.
On the other hand, if I just type mt and have Autohotkey expand to margin-top, it's much much faster, saves me much time and keeps me sane.
Basically, I have setup some hotstring in .ahk script and they work too.
However, if I press mt followed by a Tab key press, Chrome's autocomplete takes over and hotstring fails, (try once to see the problem). Instead, currently I press spacebar, or . (period) to trigger the hotstring. It works, but the problem is it leaves a space or a dot with the expanded text. [see this].
So, that's the actual reason I wanted a double period key trigger to replace Tab.
It would be great if the hotstring trigger would work with a double period key, but doesn't leave the trigger character itself and then have send Tab so as to jump to the value input of the just expanded property.
You're not really looking for a traditional remap, which is why you didn't find it from the documentation.
Remapping is just simply remapping one key to another, but you're not trying to do that. You're trying to make some action do another action.
Anyway, what you're asking is doable, but there's loads of different ways it can be achieved with difficulties varying from simple to extremely advanced & complicated.
You'll need to specify things more clearly before this can be answered properly.
Biggest questions that pop into my head right away are at least:
Should this work everywhere, or just in text input fields?
How should the original functionality of . be preserved, if at all.
(What should happen after the initial . keypress?)
Should there be some timeout between the keypresses?
Etc, this is just what I could think of right away, but surely there's more.
Anyway, for now I can give a simple implementation with a hotstring:
:*?:..::{Tab}
So this is a hotstring with the * and ? options.
I'm guessing these would probably be pretty good options for this.
So what this does, is it presses backspace twice and sends a Tab if you type ...
This should be fine for text editors, but it leaves much to be desired (the points I listed above aren't considered since I can't know what you're looking for. This is just what a default simple hotstring can offer).
Looks to me like you don't actually want the additional mapping of .. to Tab, but instead just want to update your existing hotstrings to activate immediately (without waiting for an EndChar) when the hotstring is followed by ..
Normally, you might look to the Ending Characters option to create this functionality, but since you want multiple characters to trigger this, we need to look to other options.
I will be using the example of ::mt::margin-top for my sample implementation. Extend any changes I make to these to the rest of your hotstrings in the script you screenshotted.
Here are the changes I am making to this example:
Add your .. to the end of each of your hotstrings triggers. For example ::mt::margin-top becomes ::mt..::margin-top. However, at this present, this still requires some sort of ending character to be pressed in order to proc. Let's fix that in the next step
Add the Asterisk Modifier to the hotstring. From the docs:
* (asterisk): An ending character (e.g. Space, ., or Enter) is not required to trigger the hotstring.
Final code for ::mt::margin-top example:
:*:mt..::margin-top
And extend this * insertion and .. appendation to each of your hotstrings.
Hope this helped! Lmk if you need any more help or changes.

Automatic Code Identation

I have a huge code and now for testing purpose I have to add that whole script into an infinite while loop is there any short way (without pressing space for each row) to add a space for indentation so the whole code is consider part of the one while loop ? Such as for example when we press ctrl +r it comments out the line
Ctrl-I/Cmd-I will automatically indent the file. Other wse you just select multiple row and use Tab/Shift-Tab to move them backwards and forwards.
For indentation is a must, however Matlab as a language does not care so it is not really a must to indent it. Additionally, you can just execute the code from the command line, say that you script or function is called Umar, then from the command line you just type while 1, Umar; end.
You can copy the code into notepad++.
Activate Column mode selection holding alt+shift and use the mouse to select the column of all the text you want to insert a space/tabulation/etc. and just insert it.
Final step is to copy back the code to matlab.
Matlab does not currently support column selection.
MATLAB has the option to select all your code, then press the right click and select smart indent button.
If you like to use shortcuts, just type the combination of Ctrl+A (select all) followed by Ctrl+I (smart indent)

Select text from keyboard in matlab

In emacs, it's possible to set a mark with c-space. The mark marks one end of a selection then when you move the cursor the other end of the selection moves with it.
For example, c-a, c-space, c-n, c-n selects two lines of text.
Matlab doesn't seem to have the concept of placing a mark. Is there any way to select text from the keyboard?
I'd like to do things like whack/yank a few words or comment out multiple lines without using the mouse.
I found this old question while trying to figure out the same problem. If anyone out there is still looking for how to do this, Matlab (as of version 2016a) supports keyboard selection shortcuts in the keyboard binding preferences (Preferences --> Keyboard --> Shortcuts). By default the text select functions are using the Home/End and Ctr/Shift + arrow keys to do this. I don't think the Emacs marking concept works but you could define a shortcut to your liking.
Matlab Emacs Keyboard Binding Defaults
At least you don't have to use the mouse :-)

How to turn off a weird "box" cursor and selection behavior in Netbeans?

I have some kind of weird behavior in Netbeans. I guess I accidentally entered some key combination which messed up the cursor and selection behavior. In the image you'll see what I mean: normally, if you select text across multiple lines, you'll see the behavior on the right screenshot.
But I have the behavior on the left screenshot. Also, trying to insert text at a certain position with Shift, inserts it some positions to the right (= not where the cursor is). Additionally, when the cursor blinks, it appears dashed.
The fact that the selection in the left screenshot is drawn nicely doesn't make me think of a bug, but rather of a feature. I can't seem to find the key combination to turn it off again.
So my question is, what is this feature? Why does it exist and with what key combination did I turn it on?
One possibility is you have the Rectangular Selection plugin installed.
However, the more likely candidate is the rectangular selection feature in the editor core. Find the button on your edit toolbar, and toggle it off. As per helpful comments below, this can accidentally be switched on (and toggled back off again) using:
On Windows and Linux: Ctrl + Shift + R
On Mac: Shift + Meta + R
On Mac, if the above does not work: some folks have reported that Shift + Command + R worked for them
This key combination (Ctrl+Shift+R) is used to open types etc. in Eclipse, so when switching to Netbeans many people will get stuck with this.

using idioms in vim for perl

I have the perl-support plugin enabled. now, I tried the \idd idiom shortcut which would give you a my ($,$); statement with the cursor placed on the first var. Now the second var is displayed as <+name+>. In effect the my line after entering the first variables name would be
my ( $top, $<+name+> );
If it was a code snippet I could have easily used tab to go to the next field, but it is not working in this case. How do I quickly move to changing the 2nd part of the idiom?
Those are jump targets, and you can visit them with Ctrl+J. See perlsupport-templates-jump for details.
If this is VIM, why don't you just use VIM's navigation keys for this?
3W (that is a capital W) will move you three words to the left, right onto $<+name+>.
You could also try:
f< to put the cursor on the <, and then you can change <+name+>.