Reference to JLine examples - jline

I've been trying to write a Java console program that can act upon arrow keys.
I came across JLine library that claims to be able to do this.
I've tried a few times to use the JLine library to accomplish my goal, but have been unsuccessful in doing so.
ConsoleReader reader = new ConsoleReader(System.in, new PrintWriter(System.out));
Despite using ConsoleReader.readVirtualKey(), it still waits for enter key press.
I have also tried using
UnixTerminal terminal = (UnixTerminal) Terminal.setupTerminal();
terminal.readVirtualKey(System.in);
But this doesn't work either. It always waits for Enter key and does not show the arrow keys that I pressed before pressing the Enter key.
Could someone help me with this?

A bit late perhaps, but I'm experimenting myself with jline.
This works for me:
ConsoleReader cr = new ConsoleReader();
String line = cr.readLine("type something: ")
It will probably not work if you run the program in an IDE though, e.g. it doesn't work in IntelliJ for me.

Related

Can't get input line editing to work in JLine3

I'm struggling with the basics of getting a simple console application to work with JLine3.
I've initialized it like this:
terminal = TerminalBuilder.builder()
.streams(System.in, System.out)
.build();
lineReader = LineReaderBuilder.builder().terminal(terminal).build();
and I try to read a line like this:
String in = lineReader.readLine("/>").trim();
and if the user just types text correctly, I get the right input. Backspace works for correcting the input. But moving the cursor back using the left arrow key doesn't; instead of the cursor moving, I see ^[0D displayed on the screen.
I tried various other options but nothing changed. I want to move on in due course to exploit history and auto-completion, but I'm failing at the first baby steps.
I've obviously missed something basic (but the documentation isn't good...)
Using JLine 3.13.3 on MacOS 10.13.6
If you want to create a terminal for the real console the JVM is running in, you'd rather use:
terminal = TerminalBuilder
.builder()
.system(true)
.build();
That should work better...

slow typing due to Sys.Desktop.KeyDown and Sys.Desktop.KeyUp methods

We are using Sys.Desktop.KeyDown and Sys.Desktop.KeyUp VB methods of TestComplete to type into Notepad.
For this we are using a for loop containing KeyDown and KeyUp, however for some reason, even after the for loop ends, the typing is still not complete, its typing slowly, not sure why.
I checked by removing anti-virus software, but still seeing the issue. I have also tried to use the Win32API.GetKeyState(Asc("A")) however sometimes we get 1 and sometimes 0, so really need to debug this issue out. Could anybody suggest a way to debug this issue?
Are you able to use .Keys() on the main text area object?
Something like:
Set textObject = Sys.Process("notepad").Window("Notepad", "Untitled - Notepad", 1).Window("Edit", "", 1)
Call textObject.Keys("Hello")
This is my preferred way of sending text when it is directed toward a particular object. Please refer to this link for more information on the Keys method.

Emacs on Windows: mapping the Meta key to something else than Alt

I read for a few hours on different threads for this issue without any results. Every time I was doing searches for something like
"lwindow" meta
I was always getting into EmacsWin32 code which appears to be code developed in 2006.
So, here I am to ask the question:
Is it possible to remap the Meta key, for Emacs, in Windows to something else than Alt?
I would prefer to remap it to the Windows key, but I don't think it is possible. Then the Fn (function) key would be a good alternative.
I need my Alt key operational in Emacs since it is used for all kind of things on a French keyboard.
I know nothing about Windows, but w32-pass-alt-to-system, w32-alt-is-meta, w32-lwindow-modifier, and w32-rwindow-modifier seem like good candidates (maybe combined with w32-pass-lwindow-to-system and friends).
Finally the only thing that worked for me is to use the
(require 'iso-transl)
That is making sure that the mapping of my (Canadian) French keyboard is working properly.
Then I started to use the right Alt instead of the left one. That way, I can do everything that I was doing with Ctrl+Alt.

vim advice on getting around

I have been using vim for a few days now and I really like the key bindings and the separate modes. I would really like to be able to be a little more efficient when using the various shortcuts etc.. that it has to offer.
For example I got a vim extension for visual studio and I had this line of code:
SqlCommand sqlcmd = new SqlCommand();
I wanted to get into the braces so I tried 5W, this took me to the first brace, then I pressed 'L' to go in and 'I' to go into insert mode.
I don't feel that I am using it to its potential, does anyone have any suggestions as to a quicker way they would have done that? or suggest things that I can look at to get even more efficient at editing using what vim has to offer, I would be really grateful.
Those two cheat-sheets will get you pretty far:
if your cursor is before the () on that line, you can try pressing:
%i
I think it would be the best way to go there. Of course you could do this as well:
f(a
to the question "how to get more productive"
think about those operations, you thought "complex/not productive" (like the one in your question)
try to find out a better solution by google/vim help/doc
use the new solution in your daily edit
if you cannot find better solution, ask here or other vim community, like vim-use mailing list.

can I edit Xcode code completion suggestions?

I love the code completion in Xcode, it saves me a lot of typing work. Also, it confirms my code is probably error-free in real time. However, to me, some code suggestions are disturbing. For example, when I type else after an if-statement, Xcode suggests this:
else {
statement
}
I'd like to change this to just:
else
statement
Because, I quite often just want to use one line of code there, and adding curled brackets goes much faster than removing them. The other annoying thing is the fact that using such a suggestion takes the return key, while a new line does as well. So, if I would want to use my preferred way as shown above, I would first have to press the escape key in order to stop Xcode suggesting it, and then press the return key. Not a real pain, but I think it's unnecessary.
There are some other code suggestions which I would like to change, but I think I have made my point already. Is there a way to change these code suggestions? I know Apple doesn't provide an easy way within Xcode itself, but I'm willing to dive into the finder for the file with suggestions and change it manually. Thanks!
in your example, it would work to add a space after typing else. Doing that removes the brace suggestion and you can just hit enter.

Resources