macOS Sierra - A way to move the cursor when holding down arrow key - arrow-keys

Is there a way to move the cursor when I hold down the left or right arrow key.
In the former OSX versions it used to work. After I've updated to Sierra, my cursor is not moving when I hold down the arrow key.

I don't why the settings changed after updating from OS X El Capitan to macOS Sierra, but the following instruction worked for me: https://stackoverflow.com/a/4471631/4375900
You have to open "System Preferences" then choose "Keyboard" and switch to the "Keyboard Tab".
There adjust:
"Keyboard Repeat" to "Fast", and
"Delay Until Repeat" to "Short"
and now everything is as expected.
Extra hint:
If you want an even faster key repetition, you can try to set this values:
defaults write NSGlobalDomain KeyRepeat -int 1
defaults write NSGlobalDomain InitialKeyRepeat -int 10
After that you have to perform a restart.
Also mentioned here: https://github.com/mathiasbynens/dotfiles/issues/687

I had the same problem this morning:
https://www.theguild.nl/macos-sierra-cursor-not-moving-when-holding-a-key/

Related

C++ Box drawing characters squeeze together in windows 10 console

I'm trying to print some tables in Windows console using C++.
My codes under default console settings:
cout << "╭─┬╮\n"
"├─┼┤\n"
"╰─┴╯\n";//Code I hope to work
cout << "╭ ─ ┬ ╮\n"
"├ ─ ┼ ┤\n"
"╰ ─ ┴ ╯\n";//Have an extra whitespace behind every character
gave me
The characters only take one space instead of two. They are squeezed together.
I have tried but didn't work:
Change code page to 65001(UTF-8)
Turn on and off every option except legacy mode in cmd settings hoping it would work.
Change font
I then used legacy console mode and this time it work, but for some reason I need it to work in newer mode. Can you tell me how to configure it right or is it just a bug?
OS: Windows 10 1909
Environment: CLion 2021.2.4 + MSVC v142, C++11

How to run Android-x86 with a resolution of 3840*2160 inside VMWare

I am using VMWare Workstation Player on a Smart Table under Windows and would like to get Android-x86 running there at 3840x2160 resolution.
By default, this is simply not possible. At 1152x864 is the highest resolution that the VM returns me, I could set if I use vga=ask.
I used the following link as a guide:
https://kb.vmware.com/s/article/1003
That is I have expanded the .vmx file of the VM and entered the following accordingly:
svga.vramSize = 33177600
svga.maxWidth = 3840
svga.maxHeight = 2160
Permanent change it inside the VM could be done like as example:
If the android system is started press Alt+F1.
type in
mkdir /mnt/sda
mount /dev/block/sda1 /mnt/sda
vi /mnt/sda/grub/menu.lst
press i to edit, replace quiet to nomodeset xforcevesa if you have not done it until now. Because you can make sure, that it will boot. At the end of the line add UVESA_MODE=yourdesiredresolution as example UVESA_MODE=1280x720
press Esc to return read-mode press :w then press Enter press :q then press Enter type reboot then press Enter
Okay, that was just an example. When booting up, you can press e accordingly when booting, then e again and set it individually for this boot process. As mentioned at the beginning with vga=ask you can display what should be supported. Accordingly, I would have to configure something else, since the change of the .vmx has not provided any added value.
Does anyone have experience with this and could help? Thanks in advance!

How to move cursor position when printing data in Linux Terminal using C++? [duplicate]

I'm currently designing a CLI interface for linux, and for various reasons I am not able to use ncurses. I am using exclusively C++ and the Qt framework.
Therefore, in order to have a user-friendly interface, I have to run this getch loop in a separate thread:
https://stackoverflow.com/a/912796/3605689
Which basically means I have to implement all basic functionalities (such as backspace) by myself. I have already implemented command completion and command history(like when you press tab or uparrow/downarrow in linux), but I can't figure out how to implement leftarrow/rightarrow (aka seeking through the typeahead).
Normally, I implement it like this: upon every gech which is not equal to -1, I check whether the user has pressed a special key (one that modifies the typeahead somehow). I then clear the stdout using the following function:
void inputobject::clear_line(int nletters)
{
QTextStream(stdout) << "\033[2K";
for(int i = 0; i < nletters;i++){
QTextStream(stdout) << "\b";
}
rewind(stdout);
}
And replace it with something else, effectively simulating the typeahead. For example, in the case of backspace, I would save the command call clear_line, and print the command out again, just with one less letter, behaving exactly as a normal console application would.
My real problem is with the cursor, in the case of left/rightarrow, I need to move the cursor visual in order to be able to indicate where in the text is the user seeking:
Because of the nature of how I rewrite the given stdout line to simulate the typeahead, it does not really matter where the cursor REALLY is, as long as it stays on the same line - it is just the visual that matters. How can I achieve moving the cursor visual on linux?
The answer was provided in the comment by Evilruff:
Cursor Movement
ANSI escape sequences allow you to move the cursor around the screen at will. This is more useful for full screen user interfaces generated by shell scripts, but can also be used in prompts. The movement escape sequences are as follows:
Position the Cursor:
\033[;H
Or
\033[L;Cf
puts the cursor at line L and column C.
Move the cursor up N lines:
\033[NA
Move the cursor down N lines:
\033[NB
Move the cursor forward N columns:
\033[NC
Move the cursor backward N columns:
\033[ND
Clear the screen, move to (0,0):
\033[2J
Erase to end of line:
\033[K
Save cursor position:
\033[s
Restore cursor position:
\033[u
Not using ncurses and co is a serious limitation.
It is hell to make correct input/output on shell for displaying anything.
The only others real solutions (I can't think as a solution to reimplement a ncurse-like library) I think of are:
making call to dialog (for some example www.linuxjournal.com/article/2807 and for the doc: http://linux.die.net/man/1/dialog)
using the framebuffer mecanism with Qt4 (here)

Linux - moving the console cursor visual

I'm currently designing a CLI interface for linux, and for various reasons I am not able to use ncurses. I am using exclusively C++ and the Qt framework.
Therefore, in order to have a user-friendly interface, I have to run this getch loop in a separate thread:
https://stackoverflow.com/a/912796/3605689
Which basically means I have to implement all basic functionalities (such as backspace) by myself. I have already implemented command completion and command history(like when you press tab or uparrow/downarrow in linux), but I can't figure out how to implement leftarrow/rightarrow (aka seeking through the typeahead).
Normally, I implement it like this: upon every gech which is not equal to -1, I check whether the user has pressed a special key (one that modifies the typeahead somehow). I then clear the stdout using the following function:
void inputobject::clear_line(int nletters)
{
QTextStream(stdout) << "\033[2K";
for(int i = 0; i < nletters;i++){
QTextStream(stdout) << "\b";
}
rewind(stdout);
}
And replace it with something else, effectively simulating the typeahead. For example, in the case of backspace, I would save the command call clear_line, and print the command out again, just with one less letter, behaving exactly as a normal console application would.
My real problem is with the cursor, in the case of left/rightarrow, I need to move the cursor visual in order to be able to indicate where in the text is the user seeking:
Because of the nature of how I rewrite the given stdout line to simulate the typeahead, it does not really matter where the cursor REALLY is, as long as it stays on the same line - it is just the visual that matters. How can I achieve moving the cursor visual on linux?
The answer was provided in the comment by Evilruff:
Cursor Movement
ANSI escape sequences allow you to move the cursor around the screen at will. This is more useful for full screen user interfaces generated by shell scripts, but can also be used in prompts. The movement escape sequences are as follows:
Position the Cursor:
\033[;H
Or
\033[L;Cf
puts the cursor at line L and column C.
Move the cursor up N lines:
\033[NA
Move the cursor down N lines:
\033[NB
Move the cursor forward N columns:
\033[NC
Move the cursor backward N columns:
\033[ND
Clear the screen, move to (0,0):
\033[2J
Erase to end of line:
\033[K
Save cursor position:
\033[s
Restore cursor position:
\033[u
Not using ncurses and co is a serious limitation.
It is hell to make correct input/output on shell for displaying anything.
The only others real solutions (I can't think as a solution to reimplement a ncurse-like library) I think of are:
making call to dialog (for some example www.linuxjournal.com/article/2807 and for the doc: http://linux.die.net/man/1/dialog)
using the framebuffer mecanism with Qt4 (here)

Is there a way to pause like system("pause")?

I've been looking for this on the internet for soooooo long. Is there a way you can press any key and it immediately stops the pause and carries on with executing the code but it doesn't show up the key you pressed on the screen (like system("pause"))?
People said cin.get() and stuff like that, however, if I use that, I have to press any key AND it displays on the screen and you have to press enter after that.
Since you're referencing system("pause") I guess you're using Windows, then you can use _getch to wait for any key.
Joachim Pileborg has already mentioned _getch as a Windows-specific technical solution.
However, that's a solution looking for a problem … because there's really no problem.
To see the last output from your console program, you can use any of these methods:
Run the program from the command line, e.g. an instance of Windows' standard [cmd.exe] command interpreter.
Run the program from an IDE, such that it stops at the end. E.g. in Visual Studio just use [Ctrl F5].
Run the program in a debugger, with a breakpoint on the closing } of main. E.g. in Visual Studio, add that breakpoint and run via keypress [F5].
Especially when you try the first bullet point, you will notice that having a _getch or system( "pause" ) or such at the end of the program, has no advantage and can be quite annoying!
I don't know about Windows (where apparently _getch() is the way to go) but on UNIXes you can set the standard input stream (file descriptor 0) into non-canonical mode using tcgetattr() and tcsetattr() to get the key immediately. To suppress the key presses from showing up, you'll need to also disable echoing:
termios old_tio, new_tio;
int rc = tcgetattr(0,&old_tio);
new_tio=old_tio;
new_tio.c_lflag &=(~ICANON & ~ECHO);
rc = tcsetattr(0,TCSANOW,&new_tio);
std::string value;
if (std::cin >> value) {
std::cout << "value='" << value << "'\n";
}
rc = tcsetattr(0,TCSANOW,&old_tio);
This code
first gets the current state of the terminal flags
clears the ICANON and ECHO flags
read hidden input (in this case a string but it can be an individual key, too)
restores the original settings
There is, unfortunately, no portable way of dealing with these setting, i.e., you will need to resort to platform specific uses. I think the use of tcgetattr() and tcsetattr() is applicable to POSIX systems, though.