Simple.Wpf.Terminal icon indicating copy to clipboard operation
Simple.Wpf.Terminal copied to clipboard

Key processing issues

Open john10e opened this issue 9 years ago • 32 comments

When I hit an enter key after typing a command the HandleEnterKey does not seem to capture the line. AggregateAfterPrompt() seems to always return an empty line.

I've installed the latest from NUGET version 1.29 and setup a sample similar to the examples you demonstrated. Seems to be the same problem as the last comment entered here: http://awkwardcoder.blogspot.co.uk/2014/01/simple-f-repl-in-wpf-part-4.html

john10e avatar Sep 15 '14 21:09 john10e

which OS are you building for?

oriches avatar Sep 15 '14 21:09 oriches

Windows 8 x64

From: Ollie Riches [mailto:[email protected]] Sent: Monday, September 15, 2014 3:00 PM To: oriches/Simple.Wpf.Terminal Cc: John Tenney Subject: Re: [Simple.Wpf.Terminal] Key processing issues (#6)

which OS are you building for?

— Reply to this email directly or view it on GitHubhttps://github.com/oriches/Simple.Wpf.Terminal/issues/6#issuecomment-55665728.

john10e avatar Sep 15 '14 22:09 john10e

Also if I paste a command into the terminal with a CR-LF it seems to work. I hope that helps.

From: Ollie Riches [mailto:[email protected]] Sent: Monday, September 15, 2014 3:00 PM To: oriches/Simple.Wpf.Terminal Cc: John Tenney Subject: Re: [Simple.Wpf.Terminal] Key processing issues (#6)

which OS are you building for?

— Reply to this email directly or view it on GitHubhttps://github.com/oriches/Simple.Wpf.Terminal/issues/6#issuecomment-55665728.

john10e avatar Sep 15 '14 22:09 john10e

I presume the OS is patched with the latest hotfixes via windows update.

Can you tell me the versions of the PresentationCore.dll, PresentationFramework.dll & System.Windows.Interactivity.dll referenced in the project?

oriches avatar Sep 16 '14 08:09 oriches

Yes – the Win8 x64 OS is set to auto-update per our network policy.

PresentationCore.dll: 4.0.30319.18402 PresentationFramework.dll: 4.0.30319.18402 System.Windows.Interactivity: 3.0.40218.0

I will set my program up on a Win7 machine and report back the results.

BTW- I really like this library you created!

-John

From: Ollie Riches [mailto:[email protected]] Sent: Tuesday, September 16, 2014 1:49 AM To: oriches/Simple.Wpf.Terminal Cc: John Tenney Subject: Re: [Simple.Wpf.Terminal] Key processing issues (#6)

I presume the OS is patched with the latest hotfixes via windows update.

Can you tell me the versions of the PresentationCore.dll, PresentationFramework.dll & System.Windows.Interactivity.dll referenced in the project?

— Reply to this email directly or view it on GitHubhttps://github.com/oriches/Simple.Wpf.Terminal/issues/6#issuecomment-55713504.

john10e avatar Sep 16 '14 15:09 john10e

I setup my application via click-once to run on a Win7 SP1 x64 laptop and I get the same result. Lines will appear via device/databinding but when I type into Terminal at the cursor and press enter, the HandleEnter event fires but consistently returns an empty line as a parameter.

I’ve attached the related view/viewmodels from my application. Perhaps I have Terminal configured wrong…

From: Ollie Riches [mailto:[email protected]] Sent: Tuesday, September 16, 2014 1:49 AM To: oriches/Simple.Wpf.Terminal Cc: John Tenney Subject: Re: [Simple.Wpf.Terminal] Key processing issues (#6)

I presume the OS is patched with the latest hotfixes via windows update.

Can you tell me the versions of the PresentationCore.dll, PresentationFramework.dll & System.Windows.Interactivity.dll referenced in the project?

— Reply to this email directly or view it on GitHubhttps://github.com/oriches/Simple.Wpf.Terminal/issues/6#issuecomment-55713504.

john10e avatar Sep 16 '14 15:09 john10e

Where are the attachments, I'm not seeing them?

oriches avatar Sep 16 '14 17:09 oriches

I’ve attached them again to this email. I wonder since we’re communicating via github it’s stripping off the attachments?

Here’s a pic of the original email w/ attachments I sent before:

[cid:[email protected]]

From: Ollie Riches [mailto:[email protected]] Sent: Tuesday, September 16, 2014 10:51 AM To: oriches/Simple.Wpf.Terminal Cc: John Tenney Subject: Re: [Simple.Wpf.Terminal] Key processing issues (#6)

Where are the attachments, I'm not seeing them?

— Reply to this email directly or view it on GitHubhttps://github.com/oriches/Simple.Wpf.Terminal/issues/6#issuecomment-55783840.

john10e avatar Sep 16 '14 17:09 john10e

I'm still not seeing them, can you paste the xaml & code direct into a comment?

oriches avatar Sep 16 '14 18:09 oriches

I just created a small sample app reproducing the problem with Terminal that you can download from our ftp server: ftp://ftp.ptagis.org/Utilities/TerminalTest.zip

Here’s what the xaml looks like:

<Window x:Class="TerminalTest.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:terminal="clr-namespace:Simple.Wpf.Terminal;assembly=Simple.Wpf.Terminal" xmlns:ignore="http://www.ignore.com" mc:Ignorable="d ignore" Height="300" Width="300" Title="Test Terminal" DataContext="{Binding Main, Source={StaticResource Locator}}">

<Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Skins/MainSkin.xaml" />
            <ResourceDictionary Source="/Simple.Wpf.Terminal.Themes;component/DarkTheme.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Window.Resources>

<Grid x:Name="LayoutRoot">
    <Grid.RowDefinitions>
        <RowDefinition/>
        <RowDefinition Height="35"/>
    </Grid.RowDefinitions>

    <terminal:Terminal  x:Name="TerminalOutput"
        Margin="5"
        IsReadOnlyCaretVisible="False"
        VerticalScrollBarVisibility="Visible"
        Prompt="{Binding Path=Prompt, Mode=OneWay}"
        IsReadOnly="{Binding Path=IsReadOnly, Mode=OneWay}"
        ItemsSource="{Binding Path=DeviceOutput, Mode=OneWay}">

        <terminal:Terminal.InputBindings>
            <KeyBinding Command="{Binding Path=ClearCommand, Mode=OneWay}"
                Gesture="CTRL+E" />
            <KeyBinding Command="{Binding Path=ResetCommand, Mode=OneWay}"
                Gesture="CTRL+R" />
            <KeyBinding Command="{x:Null}"
                Gesture="CTRL+L" />
        </terminal:Terminal.InputBindings>

        <!--<terminal:Terminal.ContextMenu>
            <ContextMenu>
                <MenuItem Header="Clear"
              InputGestureText="Ctrl+E"
              Command="{Binding Path=ClearCommand, Mode=OneWay}" />
                <MenuItem Header="Reset"
              InputGestureText="Ctrl+R"
              Command="{Binding Path=ResetCommand, Mode=OneWay}" />
                <Separator />
                <MenuItem Header="Copy"
              InputGestureText="Ctrl+C"
              Command="ApplicationCommands.Copy" />
                <MenuItem Header="Paste"
              InputGestureText="Ctrl+V"
              Command="ApplicationCommands.Paste" />
            </ContextMenu>
        </terminal:Terminal.ContextMenu>-->
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="LineEntered">
                <i:InvokeCommandAction Command="{Binding Path=ExecuteCommand, Mode=OneWay}"
                   CommandParameter="{Binding Path=Line, Mode=OneWay, ElementName=TerminalOutput}" />
            </i:EventTrigger>
        </i:Interaction.Triggers>
    </terminal:Terminal>

    <StackPanel Orientation="Horizontal" Grid.Row="1">
        <Label Content="Command to Execute:"/>
        <TextBlock Text="{Binding CommandText, Mode=TwoWay}"/>
    </StackPanel>
</Grid>

From: Ollie Riches [mailto:[email protected]] Sent: Tuesday, September 16, 2014 11:24 AM To: oriches/Simple.Wpf.Terminal Cc: John Tenney Subject: Re: [Simple.Wpf.Terminal] Key processing issues (#6)

I'm still not seeing them, can you paste the xaml & code direct into a comment?

— Reply to this email directly or view it on GitHubhttps://github.com/oriches/Simple.Wpf.Terminal/issues/6#issuecomment-55789430.

john10e avatar Sep 16 '14 18:09 john10e

Here’s the accompanying ViewModel code: ///

/// This class contains properties that the main View can data bind to.
/// <para>
/// See http://www.galasoft.ch/mvvm
/// </para>
/// </summary>


public class MainViewModel : ViewModelBase
{
    private string _commandText;
    /// <summary>
    /// Initializes a new instance of the MainViewModel class.
    /// </summary>
    public MainViewModel()
    {
        _commandText = string.Empty;
        ExecuteCommand = new RelayCommand<string>(OnExecuteCommand);
    }

    public string Prompt { get { return ">"; } }

    public bool IsReadOnly { get { return false; } }

    public ObservableCollection<string> DeviceOutput { get; private set; }

    public RelayCommand<string> ExecuteCommand { get; set; }

    public string CommandText
    {
        get { return _commandText; }
        set
        {
            Set(() => CommandText, ref _commandText, value);
        }
    }

    private void OnExecuteCommand(string commandText)
    {
        CommandText = commandText;
    }
    ////public override void Cleanup()
    ////{
    ////    // Clean up if needed

    ////    base.Cleanup();
    ////}
}

From: Ollie Riches [mailto:[email protected]] Sent: Tuesday, September 16, 2014 11:24 AM To: oriches/Simple.Wpf.Terminal Cc: John Tenney Subject: Re: [Simple.Wpf.Terminal] Key processing issues (#6)

I'm still not seeing them, can you paste the xaml & code direct into a comment?

— Reply to this email directly or view it on GitHubhttps://github.com/oriches/Simple.Wpf.Terminal/issues/6#issuecomment-55789430.

john10e avatar Sep 16 '14 19:09 john10e

I've created an example WPF using the control and added it to github.

Could you download the zip of the code base and tell me if it works for you?

oriches avatar Sep 16 '14 19:09 oriches

This is a screenshot of the loaded assemblies in the Simple.Wpf.Terminal.Example.

I can see I'm running later versions of the assemblies:

PresentationCore.dll 4.0.30319.34004 PresentationFramework.dll 4.00.30319.34004 System.Windows.Interactivity.dll 2.00.20525.0

image

oriches avatar Sep 16 '14 19:09 oriches

Same behavior: I type in the word TEST and hit RETURN and nothing is added to the output. I put in a breakpoint in the ExampleViewModel.AddItem and the item parameter is an empty string.

From: Ollie Riches [mailto:[email protected]] Sent: Tuesday, September 16, 2014 12:36 PM To: oriches/Simple.Wpf.Terminal Cc: John Tenney Subject: Re: [Simple.Wpf.Terminal] Key processing issues (#6)

I've created an example WPF using the control and added it to github.

Could you download the zip of the code base and tell me if it works for you?

— Reply to this email directly or view it on GitHubhttps://github.com/oriches/Simple.Wpf.Terminal/issues/6#issuecomment-55800970.

john10e avatar Sep 16 '14 19:09 john10e

I gave you bad information previously. Our loaded assemblies match: modules

Here's what the output looks like after typing TESTING and pressing RETURN: testingterminal

john10e avatar Sep 16 '14 19:09 john10e

Okay, I've managed to get your code working, but there are a couple of mistakes.

  1. Constructor not creating the DeviceOutput collection,
  2. The command execute method need to add the new line to the DeviceOutput collection,

public class MainViewModel : ViewModelBase { private string _commandText;

public MainViewModel()
{
    _commandText = string.Empty;
    DeviceOutput = new ObservableCollection<string>();
    ExecuteCommand = new RelayCommand<string>(OnExecuteCommand);
}

public string Prompt { get { return ">"; } }

public bool IsReadOnly { get { return false; } }

public ObservableCollection<string> DeviceOutput { get; private set; }

public RelayCommand<string> ExecuteCommand { get; set; }

public string CommandText
{
    get { return _commandText; }
    set
    {
        Set(() => CommandText, ref _commandText, value);
    }
}

private void OnExecuteCommand(string commandText)
{
    DeviceOutput.Add(commandText);

    CommandText = commandText;
}

}

oriches avatar Sep 16 '14 19:09 oriches

Could you take the screen shot of the loaded modules again and order them by Path for me so I can compare and look for any differences?

thanks

Ollie.

oriches avatar Sep 16 '14 20:09 oriches

Here it is (I have a different working folder so they'll be off slightly): modules

john10e avatar Sep 16 '14 20:09 john10e

ASLO: I fixed the mistakes in my sample but still getting empty string passed in as command parameter...

john10e avatar Sep 16 '14 20:09 john10e

sorry, could you do it again, order by Path but expand the version column so I can see the full version of the assembly :)

oriches avatar Sep 16 '14 20:09 oriches

No problem: modules

john10e avatar Sep 16 '14 20:09 john10e

More information: I put a breakpoint in your Example WPF Terminal.HandleEnterKey() - typed in the TESTING and let it call var line = AggregrateAfterPrompt(); As you can see in Locals the line = ""';

breakterminal

Here's the Window after ENTER pressed: testingterminal

john10e avatar Sep 16 '14 20:09 john10e

Ollie: I had my colleague download and try the example - he gets the same behavior has me. Since It's getting late on your side of the pond this can wait if need be.

john10e avatar Sep 16 '14 20:09 john10e

I've added some debugging to the codebase could you down load and run the example app in debug mode. What I get is shown below.

yeah it is getting late (10:00 pm), I'll have a look at work tomorrow if I get a spare hour.

image

oriches avatar Sep 16 '14 20:09 oriches

I've put the debug output here: ftp://ftp.ptagis.org/Utilities/TerminalDebugOutput.txt.

Looking at your screenshot above, shouldn't the 'some text' have been added to the output above the prompt after the ENTER key was pressed and then the prompt would be cleared? That's my understanding of how Terminal executes commands.

john10e avatar Sep 17 '14 00:09 john10e

I've updated the debugging in Terminal.cs, can you re-run the test and paste the debug output.

It looks like there isn't an instance of an Inline class after the Prompt Inline is inserted.

oriches avatar Sep 17 '14 08:09 oriches

I've updated Termiinal.cs again with a possible fix for the issue.

Can you test and paste the debug output.

oriches avatar Sep 17 '14 08:09 oriches

I think it’s closer. I’ve gone ahead and updated the debug output from the last ftp link I sent you.

First ENTER after ‘TEST’ doesn’t seem to work, but subsequent typing and ENTER does. It still appears the backspace/delete keys are not working however.

john10e avatar Sep 17 '14 14:09 john10e

Updated Terminal.cs again, can you test and paste the debug output.

oriches avatar Sep 17 '14 15:09 oriches

Done – see debug output on ftp.

john10e avatar Sep 17 '14 15:09 john10e