57 Commits
Author SHA1 Message Date
Dongbo Wang fbaba3e63b Fix ViModeIndicator = Cursor for Windows Terminal (#3374) 2022-07-08 15:30:50 -07:00
Jason Shirk bc40ae6f6b Remove uses of CSI # S / ScrollConsoleScreenBuffer (#790)
This fixes some weird issues in WSL and some Linux terminals.

This also works around a Windows 1809 Console bug for the Ctrl+l binding
to clear the screen by using the same escape sequence that bash uses.

Fix #724
2018-11-04 19:12:52 -08:00
Jason Shirk dfd5ae16a0 Fix tooltips and menu at bottom of buffer (#783)
A recent PR disabled the display of tooltips, and there were
some problems with the menu display when the command line
was at the bottom of the buffer and scrolling was necessary.

Fix #763 and probably #765
2018-10-22 21:51:06 -07:00
Steve Lee f92ecfe085 Enable building with dotnet cli for non-Windows (#692)
* Enable building with PSCore6
* Fix tests to work on non-Windows
* Added clipboard capability for non-Windows
2018-09-29 22:17:03 -07:00
Patrick Meinecke 46960b1fe4 Changes for Editor Hosts (VSCode/Atom) (#626) 2018-06-04 23:16:59 -07:00
Jason Shirk c3868e1250 Ignore exceptions Console.OutputEncoding
The output encoding is set for CJK characters, so if that fails, it
would be nice to know, but it comes up often (redirected input,
legacy conhost) so we just ignore the exception.
2017-12-17 22:24:25 -08:00
Jason Shirk 8bc665daed Add support for pre-Win10
Introduced a very minimal terminal emulator, enough to support the
colors used by default (ConsoleColor).

There could be some more error checking or just somehow ignoring unknown
escapes, but we'll see if this is sufficient for now.

Fix #596
2017-12-02 12:02:51 -08:00
Jason Shirk d537d01ed5 Fix CursorSize w/ redirected output
Also add logging to see errors during help generation.

Fix #593
2017-11-27 07:15:50 -08:00
Parker Snell f9773a09f5 Fix Windows console API detection (#593)
Added an input/output argument like IsHandleRedirected. There are four cases for console APIs:

    Input is not redirected; input APIs are usable.
    Output is not redirected; output APIs are usable.
    At least one of input or output is not redirected; things like SetConsoleTitle are usable.
    Both streams are redirected; we can't use any console APIs.

It's only used for the first scenario right now, but for completeness, the other cases are also handled.
2017-11-25 14:39:42 -08:00
Parker Snell 5b283a947e Implement VT input on Windows (#564)
Fix #158.
2017-11-16 22:22:51 -08:00
Jason Shirk 63d2dcf6da Portable custom key bindings
Rewrote the custom key binding code to be more portable.

Some runtime checks are necessary because of impossible to reconcile
differences.

Some Win32 P/Invoke calls are still needed due to lack of information in
the ConsoleKeyInfo.

Some keys are currently not available on Linux due to a CLR bug, others
aren't available ever because terminals don't unique character sequences
for a given key press that might differ in just the Shift or Ctrl state.
2017-10-15 22:03:56 -07:00
Jason Shirk 1d009a324e More Windows refactoring
Isolate some odds and ends of Windows specific code so the mainline code
path is not Windows specific.
2017-09-02 16:26:39 -07:00
Jason Shirk 1a623b9327 Replace COORD with Point except in ScreenCapture 2017-09-02 14:43:03 -07:00
Jason Shirk 5557fd366b Refactor CaptureScreen to isolate P/Invokes 2017-09-02 11:45:04 -07:00
Jason Shirk 602ecd496f Move more Win32 specific apis out of IConsole 2017-08-29 23:38:38 -07:00
Jason Shirk 8453d4c2c7 Fix completion at bottom of buffer 2017-08-27 15:39:33 -07:00
Jason Shirk e2fb174742 Fix rendering artifacts from shorter renders 2017-08-27 15:38:32 -07:00
Jason Shirk 96772e404f Moving onwards towards minimal P/Invokes 2017-08-14 08:56:22 -07:00
Jason Shirk 4d67c6b39d MenuComplete mostly working 2017-08-14 08:56:22 -07:00
Jason Shirk a2ae486d0d Make East Asian character support more portable
Character ranges are probably sufficient for detecting which characters
need to be rendered in cells, so I removed the Win32 specific code that
used information about the font.

We also probably don't need to detect the code page - instead assume if
a wide character is to be rendered, that the correct font is in use,
otherwise the command line looks like garbage anyway, so if we're wrong,
there is a low likelihood of it mattering.
2017-07-31 18:17:20 -07:00
Jason Shirk f90fbfa9d6 Remove redundant casts 2017-07-31 17:38:49 -07:00
Jason Shirk b4f68efe17 Remove unused local variables 2017-07-31 17:24:21 -07:00
Jason Shirk 2eb74eb0f4 Remove redundant qualifiers 2017-07-31 17:12:44 -07:00
Jason Shirk 01d1dd23f1 Remove redundant field initializers 2017-07-31 16:53:13 -07:00
Jason Shirk a02554d25d Use expression body property/method 2017-07-31 16:51:25 -07:00
Jason Shirk fc55704f83 Inline out variable parameters 2017-07-31 16:24:57 -07:00
Jason Shirk (POWERSHELL) f96bd94ece Avoid reporting an error w/ stdin/out is redirected
When stdin or stdout is redirected, PSReadLine fails with an error message that isn't very helpful.

As long as redirected stdin/out is not supported, we'll just throw an exception and let PowerShell
fall back on calling Console.ReadLine or whatever it normally does when PSConsoleHostReadline throws.
2016-09-06 11:23:47 -07:00
Jason Shirk (POWERSHELL) 0ffd1b2351 Fix warning about delcared but not used variable 2016-05-02 13:25:56 -07:00
Jason Shirk (POWERSHELL) 8335f427c6 Suppress warning about ignored return code 2016-04-27 16:43:07 -07:00
Jason Shirk (POWERSHELL) 770f579a0b Remove some unused P/Invoke declarations 2016-04-27 16:42:29 -07:00
John Starks cb23cd1250 Ignore failures from GetCurrentConsoleFontEx
GetCurrentConsoleFontEx will fail when called inside Windows Server
containers, since container consoles do not have fonts -- they always
output VT100 streams. Ignore failures from this call so that PSReadLine
does not crash immediately when loaded inside a container.

Signed-off-by: John Starks <jostarks@microsoft.com>
2016-04-22 18:40:00 -07:00
Jason Shirk (POWERSHELL) 618b4971ef Move some apis to be internal 2016-01-17 08:52:40 -08:00
jason@truewheels.net accc20dfe9 Finish refactoring so unit tests run in VS2015
The mock of the console api is complete enough so unit tests run.

It's still a hack, not exactly factored nicely to support other hosts,
but at least some of the real interface is in one place, not scattered
about.
2015-12-16 22:56:25 -08:00
Dan Thompson 89b3b0d7b7 CaptureScreen: scroll buffer with selection, add alternate movement keys. 2015-12-13 17:55:04 -08:00
jason@truewheels.net 8691e88595 Initial refactor console api usage
To get the unit tests passing in VS2015, and to help w/ possible future hosts,
I've moved most of the console api usage to a class, which is then mocked
in the unit tests.
2015-12-06 09:05:37 -08:00
jason@truewheels.net b08e74b1cd Get the real colors when copying the screen 2015-11-14 19:14:28 -08:00
Jason Shirk (POWERSHELL) 85595cde02 Mouse wheel doesn't work with powershell console
Fix is to clear the flag for capturing mouse events while in PSReadline because we would ignore them anyway.
2015-06-18 19:01:59 -07:00
Jason Shirk (POWERSHELL) 94a6ba40c9 Fix/suppress various FxCop errors 2015-06-18 18:24:23 -07:00
Jason Shirk (POWERSHELL) c986e0eae5 Rename namespace PSConsoleUtilities to Microsoft.PowerShell 2015-06-18 15:32:20 -07:00
Jason Shirk (POWERSHELL) 6408a4c96c Add copyright header 2015-06-18 15:04:49 -07:00
Yanbing Wang 14ad08d5c6 support CJK with truetype font 2015-05-18 22:08:36 -07:00
Yanbing Wang 11ded2850c support CJK with truetype font 2015-05-18 22:04:08 -07:00
Yanbing Wang 2a003d87ad add CJK support 2015-05-18 10:23:40 -07:00
jason@truewheels.net 5e991941c2 Fix menu completion for scrolling and wrapping
Menu completion would crash PowerShell when invoked from the end of the buffer.
The display also got messed up when the selected completion caused the line
length to exceed the buffer width and hence required wrapping.
2014-05-11 13:33:22 -07:00
jason@truewheels.net 2773504139 Revert "Use runtime check to allow other console-based hosts to use PSReadline."
This reverts commit f5c94f7fe2.

Conflicts:
	PSReadLine/PublicAPI.cs
2014-04-16 10:58:03 -07:00
jazzdelightsme f5c94f7fe2 Use runtime check to allow other console-based hosts to use PSReadline.
The host check in the .psd1 only allows you to specify one host. To allow
other hosts to use PSReadline, but still try to give a helpful error to
people trying to use PSReadline in other, non-console hosts (like the ISE),
we instead do a runtime check using IModuleAssemblyInitializer, wherein we
check to see if the current process has a non-hidden console window, and
emit an error if not.
2014-03-04 18:12:42 -08:00
jason@truewheels.net 2553fa3bf2 Improve key->string conversion
The strings shown for commands like Get-PSReadlineKeyHandler or
shown from functions WhatIsKey and ShowKeyBindings should now
match what you can use with Set-PSReadlineKeyHandler.

These strings will also omit +Shift in most cases because it
is usually clear from the character, e.g. the following are
equivalent but the former is preferred.

    Ctrl+?
    Ctrl+Shift+/
2013-12-14 13:23:47 -08:00
jason@truewheels.net 653b492d56 Add new functions WhatIsKey and ShowKeyBindings
WhatIsKey prompts for a key and then shows what it is bound to.

ShowKeyBindings is like running Get-PSReadlineKeyBindings, but
does so without needing to run a command and preserves the current
input line.
2013-12-11 22:41:57 -08:00
Jason Shirk 144dc45022 Ctrl-R support 2013-11-15 00:30:50 -08:00
Jason Shirk f821898ade Handle Ctrl+C like PowerShell/cmd
Ctrl+C was being processed by the system - fix was to
change the console mode.

After that, to emulate cooked input mode, we return
to the host with an empty buffer so the input is
preserved and the prompt is evaluated again.
2013-09-10 18:35:37 -07:00