Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key processing issues #6

Open
john10e opened this issue Sep 15, 2014 · 32 comments
Open

Key processing issues #6

john10e opened this issue Sep 15, 2014 · 32 comments

Comments

@john10e
Copy link

john10e commented Sep 15, 2014

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

@oriches
Copy link
Owner

oriches commented Sep 15, 2014

which OS are you building for?

@john10e
Copy link
Author

john10e commented Sep 15, 2014

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//issues/6#issuecomment-55665728.

@john10e
Copy link
Author

john10e commented Sep 15, 2014

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//issues/6#issuecomment-55665728.

@oriches
Copy link
Owner

oriches commented Sep 16, 2014

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?

@john10e
Copy link
Author

john10e commented Sep 16, 2014

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//issues/6#issuecomment-55713504.

@john10e
Copy link
Author

john10e commented Sep 16, 2014

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//issues/6#issuecomment-55713504.

@oriches
Copy link
Owner

oriches commented Sep 16, 2014

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

@john10e
Copy link
Author

john10e commented Sep 16, 2014

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//issues/6#issuecomment-55783840.

@oriches
Copy link
Owner

oriches commented Sep 16, 2014

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

@john10e
Copy link
Author

john10e commented Sep 16, 2014

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.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//issues/6#issuecomment-55789430.

@john10e
Copy link
Author

john10e commented Sep 16, 2014

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//issues/6#issuecomment-55789430.

@oriches
Copy link
Owner

oriches commented Sep 16, 2014

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
Copy link
Owner

oriches commented Sep 16, 2014

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

@john10e
Copy link
Author

john10e commented Sep 16, 2014

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//issues/6#issuecomment-55800970.

@john10e
Copy link
Author

john10e commented Sep 16, 2014

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

@oriches
Copy link
Owner

oriches commented Sep 16, 2014

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
Copy link
Owner

oriches commented Sep 16, 2014

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.

@john10e
Copy link
Author

john10e commented Sep 16, 2014

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

@john10e
Copy link
Author

john10e commented Sep 16, 2014

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

@oriches
Copy link
Owner

oriches commented Sep 16, 2014

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

@john10e
Copy link
Author

john10e commented Sep 16, 2014

No problem:
modules

@john10e
Copy link
Author

john10e commented Sep 16, 2014

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
Copy link
Author

john10e commented Sep 16, 2014

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.

@oriches
Copy link
Owner

oriches commented Sep 16, 2014

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

@john10e
Copy link
Author

john10e commented Sep 17, 2014

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.

oriches added a commit that referenced this issue Sep 17, 2014
Added more debugging to help investigate issue #6
@oriches
Copy link
Owner

oriches commented Sep 17, 2014

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 added a commit that referenced this issue Sep 17, 2014
Updated with a possible fix for issue #6 - it wasn't adding an empty Inline after the prompt of some systems, added code to explicitly add it
@oriches
Copy link
Owner

oriches commented Sep 17, 2014

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

Can you test and paste the debug output.

@john10e
Copy link
Author

john10e commented Sep 17, 2014

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.

oriches added a commit that referenced this issue Sep 17, 2014
Changes to investigate issue #6
@oriches
Copy link
Owner

oriches commented Sep 17, 2014

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

@john10e
Copy link
Author

john10e commented Sep 17, 2014

Done – see debug output on ftp.

@oriches oriches reopened this Sep 17, 2014
@oriches
Copy link
Owner

oriches commented Sep 17, 2014

running out of ideas - it appears something to do with the FlowDocument inside the RichTextBox and the CaretPosition.

I've made another subtle change, can you test and paste the debug output.

@john10e
Copy link
Author

john10e commented Sep 17, 2014

OK – I updated the debug file and tested with a pasted line from the Clipboard.

No problem dropping this. I’m not that familiar with FlowDocument/RichTextBox. When I get some time (one day?) I’ll brush up and see if I can come up with something.

I truly appreciate the effort!

oriches added a commit that referenced this issue Sep 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants