mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 07:05:24 +02:00
[192999] Terminal will crashes eclipse.exe when it received too many lines.
Now the limits in the terminal buffer lines preferences take effect
This commit is contained in:
parent
1aeb136766
commit
135be9c970
3 changed files with 55 additions and 9 deletions
|
@ -16,6 +16,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.tm.internal.terminal.view;
|
||||
|
||||
import org.eclipse.core.runtime.Preferences;
|
||||
import org.eclipse.jface.action.ActionContributionItem;
|
||||
import org.eclipse.jface.action.IMenuListener;
|
||||
import org.eclipse.jface.action.IMenuManager;
|
||||
|
@ -106,18 +107,35 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
private SettingsStore fStore;
|
||||
|
||||
private CommandInputFieldWithHistory fCommandInputField;
|
||||
|
||||
/**
|
||||
* Listens to changes in the preferences
|
||||
*/
|
||||
private final IPropertyChangeListener fPreferenceListener=new IPropertyChangeListener() {
|
||||
public void propertyChange(PropertyChangeEvent event) {
|
||||
if(event.getProperty().equals(TerminalPreferencePage.PREF_LIMITOUTPUT)
|
||||
|| event.getProperty().equals(TerminalPreferencePage.PREF_BUFFERLINES)) {
|
||||
updatePreferences();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public TerminalView() {
|
||||
Logger
|
||||
.log("==============================================================="); //$NON-NLS-1$
|
||||
}
|
||||
// TODO MSA
|
||||
// private void XXXXX() {
|
||||
// Preferences preferences = TerminalViewPlugin.getDefault().getPluginPreferences();
|
||||
// boolean bLimitOutput = preferences.getBoolean(TerminalPreferencePage.PREF_LIMITOUTPUT);
|
||||
// int bufferLineLimit = preferences.getInt(TerminalPreferencePage.PREF_BUFFERLINES);
|
||||
//
|
||||
// }
|
||||
/**
|
||||
* Update the text limits from the preferences
|
||||
*/
|
||||
private void updatePreferences() {
|
||||
Preferences preferences = TerminalViewPlugin.getDefault().getPluginPreferences();
|
||||
boolean limitOutput = preferences.getBoolean(TerminalPreferencePage.PREF_LIMITOUTPUT);
|
||||
int bufferLineLimit = preferences.getInt(TerminalPreferencePage.PREF_BUFFERLINES);
|
||||
if(!limitOutput)
|
||||
bufferLineLimit=-1;
|
||||
fCtlTerminal.setBufferLineLimit(bufferLineLimit);
|
||||
|
||||
}
|
||||
// TerminalTarget interface
|
||||
public void setState(final TerminalState state) {
|
||||
Runnable runnable=new Runnable() {
|
||||
|
@ -382,12 +400,11 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
onTerminalStatus();
|
||||
onTerminalFontChanged();
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
Logger.log("entered."); //$NON-NLS-1$
|
||||
|
||||
setPartName("Terminal"); //$NON-NLS-1$
|
||||
|
||||
TerminalViewPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPreferenceListener);
|
||||
|
||||
JFaceResources.getFontRegistry().removeListener(fPropertyChangeHandler);
|
||||
MenuManager menuMgr = getEditMenuManager();
|
||||
|
@ -399,6 +416,7 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
menu.removeMenuListener(fMenuHandlerEdit);
|
||||
|
||||
fCtlTerminal.disposeTerminal();
|
||||
super.dispose();
|
||||
}
|
||||
/**
|
||||
* Passing the focus request to the viewer's control.
|
||||
|
@ -420,6 +438,9 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
fCtlTerminal.setConnector(connectors[i]);
|
||||
}
|
||||
setCommandInputField("true".equals(fStore.get(STORE_HAS_COMMAND_INPUT_FIELD))); //$NON-NLS-1$
|
||||
updatePreferences();
|
||||
TerminalViewPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPreferenceListener);
|
||||
|
||||
}
|
||||
|
||||
private void saveSettings(ITerminalConnectorInfo connector) {
|
||||
|
|
|
@ -60,4 +60,17 @@ public interface ITerminalViewControl {
|
|||
* @return null or the current input field
|
||||
*/
|
||||
ICommandInputField getCommandInputField();
|
||||
|
||||
/**
|
||||
* @return the maximum number of lines to display
|
||||
* in the terminal view. -1 means unlimited.
|
||||
*/
|
||||
public int getBufferLineLimit();
|
||||
|
||||
/**
|
||||
* @param bufferLineLimit the maximum number of lines to show
|
||||
* in the terminal view. -1 means unlimited.
|
||||
*/
|
||||
public void setBufferLineLimit(int bufferLineLimit);
|
||||
|
||||
}
|
|
@ -844,4 +844,16 @@ public class TerminalControl implements ITerminalControlForText, ITerminalContro
|
|||
fCommandInputField.createControl(fWndParent, this);
|
||||
fWndParent.layout(true);
|
||||
}
|
||||
|
||||
public int getBufferLineLimit() {
|
||||
if(getTerminalText().isLimitOutput())
|
||||
return getTerminalText().getBufferLineLimit();
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void setBufferLineLimit(int bufferLineLimit) {
|
||||
getTerminalText().setLimitOutput(bufferLineLimit!=-1);
|
||||
getTerminalText().setBufferLineLimit(bufferLineLimit);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue