Discussion:
unknown
1970-01-01 00:00:00 UTC
Permalink
=46ormalia:

I, Christian Surlykke, hereby assign the copyright to the code-changes atta=
ched to this mail, to Per Bothner on the condition that he will make them a=
vailable under the Gnu General Public License, Version 2, =A0as published b=
y the Free Software Foundation. Other than that no restrictions on Per Both=
ners use of the changes is implied.
I declare that I am the sole author of these changes and that I know of no =
other person having any claims on it.

br. Chr.


=20

--Boundary-00=_DP4jCgiQ1tmGzPs
Content-Type: text/x-diff;
charset="us-ascii";
name="ModelineForSwt.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="ModelineForSwt.patch"

Sat May 21 20:21:23 CEST 2005 ***@surlykke.dk
* Initial modeline for Swt
diff -rN -uN gnu/jemacs/swt/ChangeLog gnu/jemacs/swt/ChangeLog
--- gnu/jemacs/swt/ChangeLog 2005-05-21 20:22:01.619357064 +0200
+++ gnu/jemacs/swt/ChangeLog 2005-05-21 20:04:47.000000000 +0200
@@ -1,3 +1,18 @@
+2005-05-21 Christian Surlykke <***@surlykke.dk>
+
+ * SwtBuffer.java: (modeline): New field. (getModeline): new method.
+ (redrawModeline): Sets the value of modeline.
+ (SwtBuffer(String, BufferContent)): Calls redrawModeline.
+ * SwtWindow.java: (swtWindowWidget): New field replacing styledText.
+ References to styledText replaced with swtWindowWidget.getStyledText()
+ throughout. (updateModeline): New method sets buffers modeline as text
+ in modeline field of swtWindowWidget. (SwtWindow(Buffer, boolean)):
+ Call updateModeline. (setBuffer): Call updateModeline.
+ (getReadyToShow): Set this SwtWindow as listener for various events on
+ styledText field of swtWindowWidget. Call updateModeline.
+ (handleCommand): Call updateModeline.
+
+
2005-05-18 Christian Surlykke <***@surlykke.dk>

* SwtKeymapper.java: (swtKey2EKey): No PRESSED flag on characters in
diff -rN -uN gnu/jemacs/swt/SwtBuffer.java gnu/jemacs/swt/SwtBuffer.java
--- gnu/jemacs/swt/SwtBuffer.java 2005-05-21 20:22:01.618357200 +0200
+++ gnu/jemacs/swt/SwtBuffer.java 2005-05-21 09:07:42.000000000 +0200
@@ -2,17 +2,20 @@

package gnu.jemacs.swt;

-import java.io.IOException;
-import java.io.Reader;
-import java.io.Writer;
-import org.eclipse.swt.custom.StyledTextContent;
-
import gnu.jemacs.buffer.Buffer;
import gnu.jemacs.buffer.Marker;
-import gnu.lists.Consumer;
import gnu.lists.CharSeq;
+import gnu.lists.FString;
import gnu.mapping.InPort;

+import java.io.Reader;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.swt.custom.StyledTextContent;
+
/**
* @author Christian Surlykke
* 11-07-2004
@@ -33,6 +36,7 @@

pointMarker = new Marker(this, 0, true);
markMarker = new Marker();
+ redrawModeline();
}

/**
@@ -40,10 +44,16 @@
*/
public void redrawModeline()
{
- // TODO Auto-generated method stub
+ modeline = new FString("-----JEmacs: " + getName() + " ---");
}
-
- /**
+
+ private FString modeline = new FString("");
+
+ public FString getModelineFormat() {
+ return modeline;
+ }
+
+ /**
* @see gnu.jemacs.buffer.Buffer#getLength()
*/
public int getLength()
diff -rN -uN gnu/jemacs/swt/SwtWindow.java gnu/jemacs/swt/SwtWindow.java
--- gnu/jemacs/swt/SwtWindow.java 2005-05-21 20:22:01.621356791 +0200
+++ gnu/jemacs/swt/SwtWindow.java 2005-05-21 09:10:50.000000000 +0200
@@ -5,10 +5,10 @@
import gnu.jemacs.buffer.Buffer;
import gnu.jemacs.buffer.EKeymap;
import gnu.jemacs.buffer.EWindow;
+import gnu.jemacs.swt.widgets.SwtWindowWidget;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.custom.VerifyKeyListener;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
@@ -25,7 +25,7 @@
*/
public class SwtWindow extends EWindow implements VerifyKeyListener, FocusListener, KeyListener, MouseListener
{
- private StyledText styledText;
+ private SwtWindowWidget swtWindowWidget;
private SwtBuffer swtBuffer;

public SwtWindow(Buffer buffer) {
@@ -35,18 +35,26 @@
public SwtWindow(Buffer buffer, boolean wantModeLine) {
super(buffer);
this.swtBuffer = (SwtBuffer) buffer;
+ updateModeline();
}

/**
*
*/
- public void getReadyToShow(Composite parent, int firstVisibleLine)
+ public void getReadyToShow(final Composite parent, final int firstVisibleLine)
{
- styledText = SwtHelper.newStyledText(parent,
- SWT.V_SCROLL | SWT.H_SCROLL,
- swtBuffer.getBufferContent(),
- this,
- firstVisibleLine);
+ SwtHelper.getDisplay().syncExec(
+ new Runnable() {
+ public void run() {
+ swtWindowWidget = new SwtWindowWidget(parent, swtBuffer.getBufferContent(), firstVisibleLine);
+ swtWindowWidget.getStyledText().addVerifyKeyListener(SwtWindow.this);
+ swtWindowWidget.getStyledText().addKeyListener(SwtWindow.this);
+ swtWindowWidget.getStyledText().addFocusListener(SwtWindow.this);
+ swtWindowWidget.getStyledText().addMouseListener(SwtWindow.this);
+ }
+ }
+ );
+ updateModeline();
}


@@ -56,7 +64,11 @@
public void setBuffer(Buffer buffer)
{
super.setBuffer(buffer);
- SwtHelper.setContent(styledText, ((SwtBuffer) buffer).getBufferContent());
+ this.swtBuffer = (SwtBuffer) buffer;
+ if (swtWindowWidget != null) {
+ SwtHelper.setContent(swtWindowWidget.getStyledText(), swtBuffer.getBufferContent());
+ updateModeline();
+ }
}


@@ -105,10 +117,11 @@
{
int oldDot = getBuffer().getDot();
super.handleCommand(command);
- SwtHelper.redraw(styledText);
+ SwtHelper.redraw(swtWindowWidget.getStyledText());
+ updateModeline();
if (oldDot != getBuffer().getDot())
{
- styledText.showSelection();
+ swtWindowWidget.getStyledText().showSelection();
}
}

@@ -133,7 +146,7 @@
*/
public int getPoint()
{
- return SwtHelper.getCaretOffset(styledText);
+ return SwtHelper.getCaretOffset(swtWindowWidget.getStyledText());
}

/**
@@ -141,7 +154,7 @@
*/
public void setDot(int offset)
{
- SwtHelper.setCaretOffset(styledText, offset);
+ SwtHelper.setCaretOffset(swtWindowWidget.getStyledText(), offset);
}

public EWindow split(Buffer buffer, int lines, boolean horizontal)
@@ -150,8 +163,10 @@
newWindow.frame = this.frame;
linkSibling(newWindow, horizontal);

- int firstVisibleLine = buffer == this.buffer ? SwtHelper.getTopIndex(styledText) : 0;
- int visibleLines = SwtHelper.getArea(styledText).height / SwtHelper.getLineHeight(styledText);
+ int firstVisibleLine = buffer == this.buffer ?
+ SwtHelper.getTopIndex(swtWindowWidget.getStyledText()) : 0;
+ int visibleLines = SwtHelper.getArea(swtWindowWidget.getStyledText()).height /
+ SwtHelper.getLineHeight(swtWindowWidget.getStyledText());

int[] weights = null;
if (!horizontal && lines > 0 && visibleLines > 1)
@@ -160,16 +175,13 @@
lines = Math.min(lines, visibleLines - 1);
weights[0] = lines;
weights[1] = visibleLines - lines;
- System.out.println("lines = " + lines);
- System.out.println("visible lines = " + visibleLines);
- System.out.println("weights = {" + weights[0] + ", " + weights[1] + "}");
}

- SwtHelper.injectSashFormAsParent(styledText, horizontal ? SWT.HORIZONTAL : SWT.VERTICAL);
- newWindow.getReadyToShow(SwtHelper.getParent(styledText), firstVisibleLine);
+ SwtHelper.injectSashFormAsParent(swtWindowWidget, horizontal ? SWT.HORIZONTAL : SWT.VERTICAL);
+ newWindow.getReadyToShow(SwtHelper.getParent(swtWindowWidget), firstVisibleLine);
if (weights != null)
- SwtHelper.setWeights(((SashForm) SwtHelper.getParent(styledText)), weights);
- SwtHelper.layout(SwtHelper.getParent(SwtHelper.getParent(styledText)));
+ SwtHelper.setWeights(((SashForm) SwtHelper.getParent(swtWindowWidget)), weights);
+ SwtHelper.layout(SwtHelper.getParent(SwtHelper.getParent(swtWindowWidget)));


return newWindow;
@@ -188,7 +200,7 @@
*/
public int getWidth()
{
- return SwtHelper.getArea(styledText).width;
+ return SwtHelper.getArea(swtWindowWidget.getStyledText()).width;
}

/**
@@ -196,7 +208,7 @@
*/
public int getHeight()
{
- return SwtHelper.getArea(styledText).height;
+ return SwtHelper.getArea(swtWindowWidget.getStyledText()).height;
}

/**
@@ -231,7 +243,7 @@
public void keyPressed(KeyEvent e)
{
handleKey(SwtKeyMapper.swtKey2EKey(e));
- SwtHelper.setCaretOffset(styledText, buffer.getDot());
+ SwtHelper.setCaretOffset(swtWindowWidget.getStyledText(), buffer.getDot());
}

public void keyReleased(KeyEvent e)
@@ -247,8 +259,8 @@
{
if (EWindow.getSelected() == this) // Is this nessecary - aren't we always selected when this event arrives?
{
- buffer.setDot(SwtHelper.getCaretOffset(styledText));
- SwtHelper.showSelection(styledText);
+ buffer.setDot(SwtHelper.getCaretOffset(swtWindowWidget.getStyledText()));
+ SwtHelper.showSelection(swtWindowWidget.getStyledText());
}
}

@@ -266,4 +278,18 @@
System.out.println("stateMask: " + EKeymap.show(e.stateMask));
}

+ public void updateModeline()
+ {
+ if (swtWindowWidget != null)
+ {
+ SwtHelper.getDisplay().asyncExec(
+ new Runnable() {
+ public void run() {
+ swtWindowWidget.getModeline().setText(swtBuffer.getModelineFormat().toString());
+ }
+ }
+ );
+ }
+ }
+
}
diff -rN -uN gnu/jemacs/swt/widgets/ChangeLog gnu/jemacs/swt/widgets/ChangeLog
--- gnu/jemacs/swt/widgets/ChangeLog 1970-01-01 01:00:00.000000000 +0100
+++ gnu/jemacs/swt/widgets/ChangeLog 2005-05-21 20:04:47.000000000 +0200
@@ -0,0 +1,6 @@
+2005-05-21 Christian Surlykke <***@surlykke.dk>
+
+ * SwtWindowWidget.java: New class, a composite widget combining two
+ styledtext widgets, one for editing and one for the modeline.
+
+
\ Intet linjeskift ved filafslutning
diff -rN -uN gnu/jemacs/swt/widgets/SwtWindowWidget.java gnu/jemacs/swt/widgets/SwtWindowWidget.java
--- gnu/jemacs/swt/widgets/SwtWindowWidget.java 1970-01-01 01:00:00.000000000 +0100
+++ gnu/jemacs/swt/widgets/SwtWindowWidget.java 2005-05-21 20:04:10.000000000 +0200
@@ -0,0 +1,53 @@
+package gnu.jemacs.swt.widgets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.custom.StyledTextContent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Class to do the graphical representation of an JEmacs window.
+ * It contains a text area (styledtext) for displaying the buffer, and a
+ * label displaying the modeline.
+ *
+ * @author Christian Surlykke
+ */
+public class SwtWindowWidget extends Composite
+{
+ private StyledText styledText;
+ private StyledText modeline;
+
+ public SwtWindowWidget(Composite parent,
+ StyledTextContent styledTextContent,
+ int firstVisibleLine)
+ {
+ super(parent, 0);
+
+ setBackground(new Color(getDisplay(), 0, 0, 0));
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.horizontalSpacing = layout.verticalSpacing = 2;
+ layout.marginWidth = layout.marginHeight = 2;
+ setLayout(layout);
+
+ System.out.println("Styledtext");
+ styledText = new StyledText(this, SWT.H_SCROLL | SWT.V_SCROLL);
+ styledText.setContent(styledTextContent);
+ styledText.setTopIndex(firstVisibleLine);
+ styledText.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ modeline = new StyledText(this, SWT.SINGLE | SWT.READ_ONLY);
+ modeline.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ }
+
+ public StyledText getStyledText() {
+ return this.styledText;
+ }
+
+ public StyledText getModeline() {
+ return this.modeline;
+ }
+}


--Boundary-00=_DP4jCgiQ1tmGzPs--

Loading...