Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
b6209a9
Add PSReadLine project.json
andyleejordan Apr 27, 2016
8bd472a
PSReadLine for Linux
palladia Apr 13, 2016
23bf8ba
Enable setting of new key bindings
palladia Apr 14, 2016
50b63f4
Enable colors
palladia Apr 22, 2016
ac2f87a
Fix resource manager
andyleejordan Apr 27, 2016
31708c9
Fix comparison of keys in dispatch dictionary
andyleejordan Apr 29, 2016
8866e33
Change default colors, and show highlighted text properly
palladia Apr 28, 2016
2975fb7
Fix Undo/Redo
palladia Apr 28, 2016
145e766
Fix ClearScreen, and disable scroll-related functions that don't work…
palladia Apr 28, 2016
15b54d8
Merge with Andy's changes
palladia Apr 29, 2016
fe8ed61
Change from check for Linux to not Windows
palladia Apr 29, 2016
04b7411
Include System.Windows.Forms only if not CORECLR
palladia Apr 29, 2016
09b1ec8
Change default history file location
palladia Apr 29, 2016
6612e53
Remove commented out line
palladia Apr 29, 2016
9625e71
Undo accidental removal of new keyword
palladia Apr 29, 2016
e888734
Fix MenuComplete
palladia Apr 29, 2016
613c4f2
Fix directory completion for different file-systems
andyleejordan Apr 30, 2016
2e1a7d0
Build PSReadLine for ConsoleHost
andyleejordan May 2, 2016
e20332f
Fix PSReadLine for net451 build
andyleejordan May 5, 2016
eacb732
Initial XDG support and folder default changes
May 24, 2016
4a41d63
Code review changes to XDG support
Jun 1, 2016
1adf27a
Changes to xdg to append powershell path
Jun 2, 2016
22477c0
Further code review changes
Jun 3, 2016
6a9e6df
Changing history to cache, removed redundant code
Jun 3, 2016
19979e1
Style changes and psreadline path change
Jun 6, 2016
7f3c328
configdefault missed in refactoring
Jun 6, 2016
6e9b977
Fix PSReadLine history path on Windows
andyleejordan Jun 6, 2016
aea43f3
Whitespace and formatting cleanups
andyleejordan Jun 6, 2016
1b09209
Rename compilationOptions to buildOptions in project.json files
andyleejordan Jun 10, 2016
40b6870
Sign all assemblies with key
andyleejordan Jun 16, 2016
26317b8
Remove authors section from product project.json
Jun 17, 2016
7156fcf
Bump framework to netstandard1.6
andyleejordan Jun 24, 2016
9220b04
Import PSReadLine change to throw when redirected
andyleejordan Jul 1, 2016
e2388e0
Add csproj files and sln for editing but not building
lzybkr Jul 5, 2016
c4b66b9
First stab addressing CORECLR vs. LINUX in PSReadLine
lzybkr Jul 6, 2016
67176b3
Introduce TTYConsole for UNIX
lzybkr Jul 7, 2016
389b3ea
Only use CHAR_INFO on Windows
lzybkr Jul 7, 2016
2abb380
Skip tone/duration on beep on LINUX
lzybkr Jul 7, 2016
6f67e9c
Refactor switch into SetDefaultBindings(EditMode)
andyleejordan Jul 15, 2016
4cb0f22
Set bindings based on options
andyleejordan Jul 15, 2016
97e4fef
Set DefaultEditMode to Emacs on Linux / OS X
andyleejordan Jul 15, 2016
07e1fba
Enable XML documentation generation
andyleejordan Jul 19, 2016
f7be60b
Fix some documentation warnings
andyleejordan Jul 19, 2016
3557539
Change preprocessor macro LINUX to UNIX
lzybkr Jul 22, 2016
09d76f7
Remove GetCharFromConsoleKey
andyleejordan Jul 19, 2016
0285870
Implement TryParseCharLiteral for Linux
andyleejordan Jul 19, 2016
e2d7a80
Revert changes made to GetGestureString
andyleejordan Jul 20, 2016
7f10c26
Use GetCharFromConsoleKey on Windows
andyleejordan Jul 20, 2016
ed7719f
Fix comparison for default ConsoleKey
andyleejordan Jul 20, 2016
4e4000c
Fix crash on file name being too long in prompt
Aug 9, 2016
08d5aff
Adding debugType portable to project.json. (#1959)
adamdriscoll Aug 23, 2016
be7c401
Use HTTPS links for go.microsoft.com
xiaoyinl Aug 24, 2016
872915d
Spelling comments (#2066)
jsoref Aug 26, 2016
6bd9f07
spelling: debug...
jsoref Aug 28, 2016
89e5ca4
add space to switch-case statement in CommandValidationVisitor.Unreso…
jsoref Sep 2, 2016
bd76c87
spelling: Hangul (unify spelling)
jsoref Sep 2, 2016
cfbc867
Fix for Linux remote script debugging hang (#2213)
PaulHigin Sep 13, 2016
63e4d77
Fix to build outside of PowerShell repo
andyleejordan Sep 16, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ x64/
*.vspscc
*.vssscc
.builds
project.lock.json

# Visual C++ cache files
ipch/
Expand Down
8 changes: 8 additions & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="powershell-core" value="https://powershell.myget.org/F/powershell-core/api/v3/index.json" />
</packageSources>
</configuration>
8 changes: 4 additions & 4 deletions PSReadLine/BasicEditing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ private bool UnresolvedCommandCouldSucceed(string commandName, Ast rootAst)
{
// The following are debugger commands that should be accepted if we're debugging
// because the console host will interpret these commands directly.
case 's': case 'v': case 'o': case 'c': case 'q': case'k': case 'l':
case 'S': case 'V': case 'O': case 'C': case 'Q': case'K': case 'L':
case 's': case 'v': case 'o': case 'c': case 'q': case 'k': case 'l':
case 'S': case 'V': case 'O': case 'C': case 'Q': case 'K': case 'L':
case '?': case 'h': case 'H':
// Ideally we would check $PSDebugContext, but it is set at function
// scope, and because we're in a module, we can't find that variable
Expand Down Expand Up @@ -523,7 +523,7 @@ public static void AddLine(ConsoleKeyInfo? key = null, object arg = null)
[SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
public static void InsertLineAbove(ConsoleKeyInfo? key = null, object arg = null)
{
// Move the current postion to the beginning of the current line and only the current line.
// Move the current position to the beginning of the current line and only the current line.
if (_singleton.LineIsMultiLine())
{
int i = Math.Max(0, _singleton._current - 1);
Expand Down Expand Up @@ -554,7 +554,7 @@ public static void InsertLineAbove(ConsoleKeyInfo? key = null, object arg = null
[SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
public static void InsertLineBelow(ConsoleKeyInfo? key = null, object arg = null)
{
// Move the current postion to the end of the current line and only the current line.
// Move the current position to the end of the current line and only the current line.
if (_singleton.LineIsMultiLine())
{
int i = _singleton._current;
Expand Down
4 changes: 2 additions & 2 deletions PSReadLine/Changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ New features:
* SamplePSReadlineProfile.ps1 added with examples of custom key bindings
* Word movement takes DigitArgument
* HistoryNoDuplicates now works a little differently
- Dupicates are saved (it was a dubious memory optimization anyway)
- Duplicates are saved (it was a dubious memory optimization anyway)
- Recall will recall the most recently executed item instead of the first
* When at the last word, NextWord/ForwardWord now move to the end of line instead
of the last character of the word.
Expand Down Expand Up @@ -227,7 +227,7 @@ Bugs fixed:
* Ctrl+R with long search lines no longer causes big problems

Behavior change:
* Word functions now use delimiters. The previous behavior is availble
* Word functions now use delimiters. The previous behavior is available
via a Shell*Word function, e.g. instead of KillWord, use ShellKillWord.

### Version 1.0.0.4
Expand Down
65 changes: 52 additions & 13 deletions PSReadLine/Cmdlets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
using System.Management.Automation.Language;
using System.Reflection;
using System.Linq;
#if CORECLR
using System.Runtime.InteropServices;
using Microsoft.PowerShell.Internal;
#endif

namespace Microsoft.PowerShell
{
Expand Down Expand Up @@ -69,20 +73,31 @@ public enum HistorySaveStyle

public class PSConsoleReadlineOptions
{
#if UNIX // TODO: why different schemes for LINUX?
public const ConsoleColor DefaultCommentForegroundColor = ConsoleColor.Magenta;
public const ConsoleColor DefaultOperatorForegroundColor = ConsoleColor.Gray;
public const ConsoleColor DefaultParameterForegroundColor = ConsoleColor.Green;
#else
public const ConsoleColor DefaultCommentForegroundColor = ConsoleColor.DarkGreen;
public const ConsoleColor DefaultOperatorForegroundColor = ConsoleColor.DarkGray;
public const ConsoleColor DefaultParameterForegroundColor = ConsoleColor.DarkGray;
#endif
public const ConsoleColor DefaultKeywordForegroundColor = ConsoleColor.Green;
public const ConsoleColor DefaultStringForegroundColor = ConsoleColor.DarkCyan;
public const ConsoleColor DefaultOperatorForegroundColor = ConsoleColor.DarkGray;
public const ConsoleColor DefaultVariableForegroundColor = ConsoleColor.Green;
public const ConsoleColor DefaultCommandForegroundColor = ConsoleColor.Yellow;
public const ConsoleColor DefaultParameterForegroundColor = ConsoleColor.DarkGray;
public const ConsoleColor DefaultTypeForegroundColor = ConsoleColor.Gray;
public const ConsoleColor DefaultNumberForegroundColor = ConsoleColor.White;
public const ConsoleColor DefaultMemberForegroundColor = ConsoleColor.Gray;
public const ConsoleColor DefaultEmphasisForegroundColor = ConsoleColor.Cyan;
public const ConsoleColor DefaultErrorForegroundColor = ConsoleColor.Red;

public const EditMode DefaultEditMode = EditMode.Windows;
public const EditMode DefaultEditMode =
#if UNIX
EditMode.Emacs;
#else
EditMode.Windows;
#endif

public const string DefaultContinuationPrompt = ">> ";

Expand All @@ -105,7 +120,7 @@ public class PSConsoleReadlineOptions

/// <summary>
/// When displaying possible completions, either display
/// tooltips or dipslay just the completions.
/// tooltips or display just the completions.
/// </summary>
public const bool DefaultShowToolTips = false;

Expand Down Expand Up @@ -151,8 +166,32 @@ public PSConsoleReadlineOptions(string hostName)
WordDelimiters = DefaultWordDelimiters;
HistorySearchCaseSensitive = DefaultHistorySearchCaseSensitive;
HistorySaveStyle = DefaultHistorySaveStyle;
HistorySavePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
+ @"\Microsoft\Windows\PowerShell\PSReadline\" + hostName + "_history.txt";

string historyFileName = hostName + "_history.txt";
#if UNIX
// PSReadline does not have access to Utils.CorePSPlatform. Must set PSReadline path separately
string historyPath = System.Environment.GetEnvironmentVariable("XDG_DATA_HOME");

if (!String.IsNullOrEmpty(historyPath))
{
historyPath = System.IO.Path.Combine(historyPath, "powershell", "PSReadLine", historyFileName);
HistorySavePath = historyPath;
}
else
{
// History is data, so it goes into .local/share/powershell folder
HistorySavePath = System.IO.Path.Combine(Environment.GetEnvironmentVariable("HOME"),
".local",
"share",
"powershell",
"PSReadLine",
historyFileName);
}
#else
HistorySavePath = System.IO.Path.Combine(Environment.GetEnvironmentVariable("APPDATA"),
@"Microsoft\Windows\PowerShell\PSReadline\",
historyFileName);
#endif
CommandValidationHandler = null;
CommandsToValidateScriptBlockArguments = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
Expand Down Expand Up @@ -342,7 +381,7 @@ internal void SetBackgroundColor(TokenClassification tokenKind, ConsoleColor col
}
}

[Cmdlet("Get", "PSReadlineOption", HelpUri = "http://go.microsoft.com/fwlink/?LinkId=528808")]
[Cmdlet("Get", "PSReadlineOption", HelpUri = "https://go.microsoft.com/fwlink/?LinkId=528808")]
[OutputType(typeof(PSConsoleReadlineOptions))]
public class GetPSReadlineOption : PSCmdlet
{
Expand All @@ -353,7 +392,7 @@ protected override void EndProcessing()
}
}

[Cmdlet("Set", "PSReadlineOption", HelpUri = "http://go.microsoft.com/fwlink/?LinkId=528811")]
[Cmdlet("Set", "PSReadlineOption", HelpUri = "https://go.microsoft.com/fwlink/?LinkId=528811")]
public class SetPSReadlineOption : PSCmdlet
{
[Parameter(ParameterSetName = "OptionsSet")]
Expand Down Expand Up @@ -633,7 +672,7 @@ protected IDisposable UseRequestedDispatchTables()
}
}

[Cmdlet("Set", "PSReadlineKeyHandler", HelpUri = "http://go.microsoft.com/fwlink/?LinkId=528810")]
[Cmdlet("Set", "PSReadlineKeyHandler", HelpUri = "https://go.microsoft.com/fwlink/?LinkId=528810")]
public class SetPSReadlineKeyHandlerCommand : ChangePSReadlineKeyHandlerCommandBase, IDynamicParameters
{
[Parameter(Position = 1, Mandatory = true, ParameterSetName = "ScriptBlock")]
Expand All @@ -658,9 +697,9 @@ protected override void EndProcessing()
if (ParameterSetName.Equals(FunctionParameterSet))
{
var function = (string)_dynamicParameters.Value[FunctionParameter].Value;
MethodInfo mi = typeof (PSConsoleReadLine).GetMethod(function);
var keyHandler = (Action<ConsoleKeyInfo?, object>)
Delegate.CreateDelegate(typeof (Action<ConsoleKeyInfo?, object>),
typeof (PSConsoleReadLine).GetMethod(function));
mi.CreateDelegate(typeof (Action<ConsoleKeyInfo?, object>));
BriefDescription = function;
PSConsoleReadLine.SetKeyHandler(Chord, keyHandler, BriefDescription, Description);
}
Expand Down Expand Up @@ -708,7 +747,7 @@ public object GetDynamicParameters()
}
}

[Cmdlet("Get", "PSReadlineKeyHandler", HelpUri = "http://go.microsoft.com/fwlink/?LinkId=528807")]
[Cmdlet("Get", "PSReadlineKeyHandler", HelpUri = "https://go.microsoft.com/fwlink/?LinkId=528807")]
[OutputType(typeof(KeyHandler))]
public class GetKeyHandlerCommand : PSCmdlet
{
Expand Down Expand Up @@ -752,7 +791,7 @@ protected override void EndProcessing()
}
}

[Cmdlet("Remove", "PSReadlineKeyHandler", HelpUri = "http://go.microsoft.com/fwlink/?LinkId=528809")]
[Cmdlet("Remove", "PSReadlineKeyHandler", HelpUri = "https://go.microsoft.com/fwlink/?LinkId=528809")]
public class RemoveKeyHandlerCommand : ChangePSReadlineKeyHandlerCommandBase
{
[ExcludeFromCodeCoverage]
Expand Down
21 changes: 12 additions & 9 deletions PSReadLine/Completion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public partial class PSConsoleReadLine
private CommandCompletion _tabCompletions;
private Runspace _runspace;

// String helper for directory paths
private static string DirectorySeparatorString = System.IO.Path.DirectorySeparatorChar.ToString();

// Stub helper method so completion can be mocked
[ExcludeFromCodeCoverage]
CommandCompletion IPSConsoleReadLineMockableMethods.CompleteInput(string input, int cursorIndex, Hashtable options, System.Management.Automation.PowerShell powershell)
Expand Down Expand Up @@ -273,36 +276,36 @@ private void DoReplacementForCompletion(CompletionResult completionResult, Comma

private static string GetReplacementTextForDirectory(string replacementText, ref int cursorAdjustment)
{
if (!replacementText.EndsWith("\\", StringComparison.Ordinal))
if (!replacementText.EndsWith(DirectorySeparatorString , StringComparison.Ordinal))
{
if (replacementText.EndsWith("\\'", StringComparison.Ordinal) || replacementText.EndsWith("\\\"", StringComparison.Ordinal))
if (replacementText.EndsWith(String.Format("{0}\'", DirectorySeparatorString), StringComparison.Ordinal) ||
replacementText.EndsWith(String.Format("{0}\"", DirectorySeparatorString), StringComparison.Ordinal))
{
cursorAdjustment = -1;
}
else if (replacementText.EndsWith("'", StringComparison.Ordinal) || replacementText.EndsWith("\"", StringComparison.Ordinal))
else if (replacementText.EndsWith("'", StringComparison.Ordinal) ||
replacementText.EndsWith("\"", StringComparison.Ordinal))
{
var len = replacementText.Length;
replacementText = replacementText.Substring(0, len - 1) + '\\' + replacementText[len - 1];
replacementText = replacementText.Substring(0, len - 1) + System.IO.Path.DirectorySeparatorChar + replacementText[len - 1];
cursorAdjustment = -1;
}
else
{
replacementText = replacementText + '\\';
replacementText = replacementText + System.IO.Path.DirectorySeparatorChar;
}
}
return replacementText;
}

private static void InvertSelectedCompletion(CHAR_INFO[] buffer, int selectedItem, int menuColumnWidth, int menuRows)
private static void InvertSelectedCompletion(BufferChar[] buffer, int selectedItem, int menuColumnWidth, int menuRows)
{
var selectedX = selectedItem / menuRows;
var selectedY = selectedItem - (selectedX * menuRows);
var start = selectedY * _singleton._console.BufferWidth + selectedX * menuColumnWidth;
for (int i = 0; i < menuColumnWidth; i++)
{
int j = i + start;
buffer[j].ForegroundColor = (ConsoleColor)((int)buffer[j].ForegroundColor ^ 7);
buffer[j].BackgroundColor = (ConsoleColor)((int)buffer[j].BackgroundColor ^ 7);
buffer[i + start].Inverse = true;
}
}

Expand Down
10 changes: 5 additions & 5 deletions PSReadLine/ConsoleBufferBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ namespace Microsoft.PowerShell
{
internal class ConsoleBufferBuilder
{
private List<CHAR_INFO> buffer;
private List<BufferChar> buffer;
private IConsole _console;

public ConsoleBufferBuilder(int capacity, IConsole console)
{
buffer = new List<CHAR_INFO>(capacity);
buffer = new List<BufferChar>(capacity);
_console = console;
}

CHAR_INFO NewCharInfo(char c)
BufferChar NewCharInfo(char c)
{
return new CHAR_INFO
return new BufferChar
{
UnicodeChar = c,
BackgroundColor = _console.BackgroundColor,
Expand All @@ -45,7 +45,7 @@ public void Append(char c, int count)
}
}

public CHAR_INFO[] ToArray()
public BufferChar[] ToArray()
{
return buffer.ToArray();
}
Expand Down
Loading