From e06a68c31e3226c87311f0da42b11d75fff9deb3 Mon Sep 17 00:00:00 2001 From: Martin Oberhuber Date: Fri, 29 Feb 2008 16:48:59 +0000 Subject: [PATCH] [196447] The optional terminal input line should be resizeable --- .../control/CommandInputFieldWithHistory.java | 35 +++++++++++++++++-- .../emulator/VT100TerminalControl.java | 5 +-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java index 5403e4ce613..a41fd2b36cb 100644 --- a/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java +++ b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java @@ -8,6 +8,7 @@ * Contributors: * Michael Scharf (Wind River) - initial implementation * Michael Scharf (Wing River) - [211659] Add field assist to terminal input field + * Michael Scharf (Wing River) - [196447] The optional terminal input line should be resizeable *******************************************************************************/ package org.eclipse.tm.internal.terminal.control; import java.util.ArrayList; @@ -24,8 +25,12 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Sash; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter; @@ -108,6 +113,7 @@ public class CommandInputFieldWithHistory implements ICommandInputField { * The input text field. */ private Text fInputField; + private Sash fSash; public CommandInputFieldWithHistory(int maxHistorySize) { fMaxSize=maxHistorySize; } @@ -200,8 +206,31 @@ public class CommandInputFieldWithHistory implements ICommandInputField { fEditedHistory=null; fEditHistoryPos=0; } - public void createControl(Composite parent,final ITerminalViewControl terminal) { - fInputField=new Text(parent, SWT.SINGLE|SWT.BORDER); + public void createControl(final Composite parent,final ITerminalViewControl terminal) { +// fSash = new Sash(parent,SWT.HORIZONTAL|SWT.SMOOTH); + fSash = new Sash(parent,SWT.HORIZONTAL); + final GridData gd_sash = new GridData(SWT.FILL, SWT.CENTER, true, false); + gd_sash.heightHint=5; + fSash.setLayoutData(gd_sash); + fSash.addListener (SWT.Selection, new Listener () { + public void handleEvent (Event e) { + // no idea why this is needed + GridData gdata = (GridData) fInputField.getLayoutData(); + Rectangle sashRect = fSash.getBounds (); + Rectangle containerRect = parent.getClientArea (); + + int h=fInputField.getLineHeight(); + // make sure the input filed hight is a multiple of the line height + gdata.heightHint = Math.max(((containerRect.height-e.y-sashRect.height)/h)*h,h); + // do not show less then one line + e.y=Math.min(e.y,containerRect.height-h); + fInputField.setLayoutData(gdata); + parent.layout(); + // else the content assist icon will be replicated + parent.redraw(); + } + }); + fInputField=new Text(parent, SWT.MULTI|SWT.BORDER|SWT.WRAP|SWT.V_SCROLL); GridData data=new GridData(SWT.FILL, SWT.FILL, true, false); boolean installDecoration=true; if(installDecoration) { @@ -262,6 +291,8 @@ public class CommandInputFieldWithHistory implements ICommandInputField { fInputField.getParent().layout(true); } public void dispose() { + fSash.dispose(); + fSash=null; fInputField.dispose(); fInputField=null; diff --git a/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index c76f0279271..a45377bc392 100644 --- a/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2003, 2008 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -19,6 +19,7 @@ * Martin Oberhuber (Wind River) - [207785] NPE when trying to send char while no longer connected * Michael Scharf (Wind River) - [209665] Add ability to log byte streams from terminal * Ruslan Sychev (Xored Software) - [217675] NPE or SWTException when closing Terminal View while connection establishing + * Michael Scharf (Wing River) - [196447] The optional terminal input line should be resizeable *******************************************************************************/ package org.eclipse.tm.internal.terminal.emulator; @@ -518,7 +519,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC GridLayout layout=new GridLayout(); layout.marginWidth=0; layout.marginHeight=0; - + layout.verticalSpacing=0; fWndParent.setLayout(layout); ITerminalTextDataSnapshot snapshot=fTerminalModel.makeSnapshot();