Community
Participate
Working Groups
We need a debug console with command line history. The current console does not provide this. We are currently using introspection to allow us to hook into ProcessConsole to add command line history. Pressing ctrl up arrow and ctrl down arrow allow us to navigate the history. Introspection is a very fragile way of doing it. Every time there is a new Eclipse release, we have to update our code to track implementation changes in ProcessConsole. We would like one of these 1) Provide a command line history in ProcessConsole. or 2) Change ProcessConsole with supported API to allow developers to add a command line history. Here is a high level overview of our fragile implementation just to give you a sense of what is involved. Given an IOConsoleViewer use intropsection to replace the documentListener field with a new listener. The new listener will function like the original version except that if text is being appended at the end of the document, it will move the cursor there. This works even if the text being appended has no new-line inserted yet. Given a process console, get the document, and replace the partitioner. The new partitioner functions exactly like the old one with the exception that when user input (a command typed by the user, terminated with a newline) is sent to the input stream, the user's command is also added to the command history for the console's document. Add handlers for ctrl up arrow and ctrl down arrow. These handlers grab the appropriate line in the history and stuff it in to the console. To stuff it into the console, we call upone our improved document partitioner to do this. The improved partitioner ensures the last partition is not read only. If it is, a new partition is created which is read write. This last partition, newly created or not is where history is inserted. The last partition may already be read write if the user has already started typing a line. In which case this partial line is replace with the history line. Our implementation makes simplifying assumptions about types that we know to be true for our use case.
It will be a good addition. If you can provide the implementation, we can work to add the feature.
Created attachment 288974 [details] Patch to add history to the ProcessConsole Bug 561001 - Debug console with command line history History has been added to the ProcessConsole. Use ctrl-up and ctrl-down to move through the history. The code for the history has actually been added to the package for IOConsole. However, I didn't want to change the behavior of IOConsole. The ProcessConsole constructor simply passes a flag to IOConsole to enable the history. The existing constructor for IOConsole passes a false to a new verion of the IOConsole constructor to disable history. Thus existing code using the existing constructor will still work as before. The actual work for collecting history is in IOConsolePartitioner. The constructor for IOConsoleInputStream has been made public. This is the stream which receives keyboard input from a console once enter is pressed. By making it public, a developer can set their own input stream. This allows for logging, transforming and filtering user input before it is sent to the process. IOConsole has a method to set the input stream, and another to get the input stream. getInputStream() returns IOConsoleInputStream. However, setInputStream() accepts the more basic InputStream. I'm not sure why the assymetry. The only way IOConsoleParition will pass the user entered text to the stream is if it is a IOConsoleInputStream. I fixed a bug in IOConsolePartitioner.computePartitioning. There was a simple off by one type of error while looping through partitions to see which ones spanned the input region. The loop was exited too early. I fixed a bug in IOConsoleViewer. When a user types input and the cursor is in a non-writeable partition, there was code to insert the text into the beginning of the writable partition. However it's more natural to add it to the end of that partition. Consider the situation where the user has typed some input, perhaps "show info ". Then goes to a location earlier in the console to select a variable name and copy and paste it. The user expects the pasted text to go after the text already typed. That is they expect "show info var", not "varshow info ". In TextConsoleViewer, I changed the reveal job to optionally move the cursor to the end of the text widget. This job is invoked if auto scroll is on. When a document modification occurs at the end of the document, the cursor is also moved to the end of the document. This is useful for when a history line is placed in the document.
Hi Chris, the project bug tracker moved, see https://github.com/eclipse-platform/eclipse.platform.debug Would be great if you could: 1) Separate feature from bug fixes 2) Split your patch in few self contained pull requests each dedicated to one fix/feature 3) Push them to github Thanks!
Thanks for the quick response. I'll do my best to figure out the new procedure.
Moved to Github: https://github.com/eclipse-platform/eclipse.platform.debug/issues/113