Unable to use X clipboard in Screen - clipboard

I read the following code in Unix Power Tools on page 117
*VT100.Translations: #override\
Button1 <Btn3Down>: select-end(primary,CUT_BUFFER0,CLIPBOARD)\n\
!Shift <Btn2Up>: insert-selection(CLIPBOARD)\n\
~Shift ~Ctrl ~Meta <Btn2Up>: insert-selection(primary,CUT_BUFFER0)
I have not managed to see any effect of the above code.
How can you use X clipboard in Screen, without your mouse?

Using the mouse. Left-click drag to select and usually the middle mouse button pastes but some terminals may differ (PuTTY uses right-click). If you only have two buttons you click them both together (left mouse button + right mouse button).
In reply to comment below ("Can you do it without your mouse?"):
ctrl-insert : copy
shift-insert : paste
shift-delete : cut
shift-ctrl-C : copy
shift-ctrl-V : paste
Not all applications will support the last three (though Konsole does). In fact most console applications will not allow you to delete text once it's printed.
As far as selecting text without a mouse I'm not sure there's a generic mechanism for that. It's probably terminal and/or application specific (ie, vim has it's own keys for marking and copying text - but only within vim). You could do it with mouse emulation but I'm sure that would be a painful process.
You can't use the traditional Mac/Windows shortcuts in a terminal because they were reserved for different actions long before these OS existed (ie, Ctrl-C terminates the running process).
I'm trying to use Ctrl-C in X
X does not handle these operations directly, they are handled by the application. That's why modern GUI programs like Firefox or Gedit support Ctrl-C for copy but terminals and command-line programs generally do not. As I said, it's a conflict in established conventions and Ctrl-C for kill got in first.
BTW, you could do some key-remapping if it drives you nuts but then you would be learning bad habits when you use a different machine. Best to just get used to it or do most of your editing in a GUI application.
More Information
EDIT: For a Mac, this may help: MacOSX-to-Konsole or This or This. It looks like you need to replace Ctrl with Command on Mac keyboards. It seems like Terminal the mac console has a right-click context menu for copy-paste so to do it the traditional way you me need to install a different console program or change some settings in Terminal.

Related

How does on-screen (virtual) keyboard works in Win10

I haven't find anything relevant in Google or any Microsoft site about it so I decided to ask a question here.
Everybody knows that in Win-based OS there is a virtual keyboard. I also know that *nix based OS, have it too. So, the question is about:
HOW DOES IT WORK INSIDE?
I mean, let's have an example that I opened on screen keyboard in Windows 10. What's the actual difference between:
input via hardware keyboard: when I'm using it, like I press X button
..and using a virtual keyboard, when I press the same button
Imagine, I have an admin access to terminal/computer, is there any option to track/distinguish that in the second time I pressed button not on hardware keyboard, but on-screen (by mouse clicking) version of it?
And there are also many different software, like AutoIt (yes, it's a language, but it's relevant to this example) that emulating pressing the X button. How does they work in Win-based OS? Do they "in-common" with default on-screen keyboard and using the same driver/WinAPI or there is a difference between them?
And the second case, between:
default on-screen keyboard
compilated AutoIt script
..any other software that emulating press X button
I guess the only way to find out "how exactly button was pressed" is to check current processes list via taskmgr and find out have anything been launched or not. Or I'm totally wrong here, and missing something?
THE SCOPE
I have written a node.js script which emulates button pressing behaviour in windows app.
TL:DR business logic short => open notepad.exe and type `Hello world`
And could someone give me any advice/recommend any powershell/bat script (or any other solution) with demonstration of Get­Async­Key­State check behavior? With which I could easily check my own node.js script (not by functional of it, but by triggering press the X button event)
I found an answer for node.js case here: Detecting Key Presses Across Applications in Powershell
SendInput is the preferred method to generate user input in software. The Windows on-screen keyboard probably uses it for everything except Ctrl+Alt+Delete which I believe has some kind of special handling. The on-screen keyboard is only able to generate Ctrl+Alt+Delete in certain configurations.
Software-generated input is merged with normal hardware input in the RIT (Raw Input Thread) in the kernel.
A low-level keyboard hook can detect software-generated input.

Is there a way to determine if a terminal is focused without asking the window manager?

I want to change some tmux styling when the terminal loses focus/becomes inactive (i.e. when I've clicked on an open Google Chrome window). I know I could check with the window manager to see which application window is focused, but this doesn't work across window managers.
Do terminal emulators themselves expose this information at all?
I tried running showkey -a to see if any escape sequence was sent when focus was lost, and it doesn't look like it.
I think some terminals implement this, but not all, based on this comment on the issue tracker for the vim-tmux-focus-events plugin:
About the question "I was expecting the event to fire when changing focus between different windows in my window manager": yea, I see how that would be very useful. I think this might be dependent on the terminal application you're using. I just tested this on OSX and here's some quick results:
it's working for iTerm when tmux is running inside the window
not working for iTerm running plain bash + vim inside (no tmux)
not working for Terminal.app (with or without tmux)
[...]
So, if I'm not wrong, it's up to terminal applications to implement "focus gained", "focus lost" functionality.
I have a vague memory (though I don't remember for sure) that focus gain/loss might have worked for me when using that plugin and gnome-terminal, so it might be worth a try.

mouse capturing differences between Terminal.app with MouseTerm SIMBL plugin and iTerm2

iTerm2:
Mouse reporting works out of the box, works in Vim, works fully in Tmux, mouse wheel reporting works in Vim and for navigating Tmux history, but mouse wheel reporting does not work in manpages, does not work in git log, does not work in less
Terminal.app:
Mouse reporting does not work out of the box, but once installed mouse wheel reporting works everywhere including less and manpages and git log, etc. However mouse click+drag fails in Tmux, but still works in Vim.
So I'd rather use just one of these terminal apps, and I am particularly digging the immense feature set of iTerm2 (e.g. mouse-over to select which term to input to beats the hell out of anything Tmux can offer since it is zero keys to switch contexts) so I'd prefer if I can get mouse wheel reporting working fully in those programs.
I am having a hard time trying to debug the terminal codes being sent because the only way I can intercept them is through Vim, (as ctrl+V followed by scroll in my terminal will just have it scroll the terminal buffer) but Vim seems to be doing everything correctly.
Update: According to mouseterm project, it seems to be using a feature called "Simulated mouse wheel scrolling" to scroll programs like less... maybe I can configure iTerm to do the same. Somehow. I do believe PuTTY also accomplishes this, and I'd like to have at least the functionality I can get on Windows on the Mac... Nope, I'm just spoiled by the neatness of MouseTerm.
Although less (which is also used in git log) does not use mouse reporting itself,
iTerm2 can be configured to send up/down-arrow escape codes for scrolling
(from mouse wheel or trackpad two-finger swipe)
and less understands those.
See my answer
to a related question about how to set this up for iTerm2.
less does not actually recognize any terminal mouse events. (As such, tools that use it, like man and git log will not recognize mouse events either.) Something else you've done must be making it appear to support mouse events.
If you want the mouse wheel to work in your pager, you'll need to find a pager other than less which supports it. You might be able to put something together using view (vim in read-only mode), but applications like man which output content with control codes will be an issue there.

How do you duplicate a shell instance in Unix?

My specific problem is the following: I am using Mac OS X with the Visor app for terminal. This lets me do cool pop-in/out stuff with terminal for quick access. The problem is, I lose the ability to move the window around and re-size it, something that becomes important when I start opening up multiple buffers in emacs and want to view some at the same time in a window larger than 80 wide.
Does anyone know how to duplicate a shell window/instance, so that a new window appears with the same history, current working dir, aliases, etc...? Even more specifically, can this be done in Mac OS X such that the new window is in a different "style", (basic, pro, sands, etc..).
I'm not familiar with Visor, but simply using a terminal emulator such as screen might give you what you need. From a terminal, invoke 'screen'. That will give you a shell prompt. From another terminal, invoke 'screen -x'. Now each terminal will be attached to the same shell, with the same history, etc. See screen(1) for details.

Remembering terminal states in OS X (like Fluid for the shell...)

I have a few different things open in the terminal whenever I'm developing -- log tailing, Ruby console, plain shell in a certain directory, and so on.
How do I:
start all those things at once, hopefully in the right position on the screen?
make them distinct so I can switch to them with Quicksilver / Alt-Tab?
Fluid solved this problem with all of my web apps, so now I want to do it with my terminals.
And while we're on the topic, has anyone found a working solution for getting OS X to remember window positions on an external monitor? If I unplug it and plug it back in, I have to drag everything back to the same position (although at least Mercury Mover makes it possible to do it with the keyboard.)
Open Terminal, and go into Preferences, then go into the settings tab, and create a new setting for each of your windows that you want. Either give them all different colour schemes, or duplicate a colour scheme multiple times for them all to have the same settings. Under the shell sub-tab, add "Run command" to be run at shell startup. (This is the command that will cd to the directory you want, or tail a log).
Then initialise the windows as you want. Then click Window in the main menu and select Save Windows as Group...
In OSX Yosemite you can use (in Terminal) Window -> Save group. It will do all the work for you.

Resources