0 Members and 2 Guests are viewing this topic.
I really need to add Undo/Redo so that this has some value, but I can't do it, anybody knows how to?
Nice!definitely a fine program Single issue I can say is the text size, if I had to read a whole page my eyes would really start to hurt...
Quote from: ScoutDavid on December 23, 2010, 02:24:28 pmI really need to add Undo/Redo so that this has some value, but I can't do it, anybody knows how to?I know how to, but for a text editor, it's a little more complicated. Essentially, you need to store a certain number of "actions" into a buffer (Say 30), and then be able to undo and redo them. I would have two stacks. One is for Undo, and one is for Redo. Actions go on to the Undo stack. When you "undo" them, they swap to the redo stack, along with being undone. When you redo, if there are any on the "redo" stack, you swap them to the undo stack, and redo them.As for how much text you decide is an "action", or how you deal with that, is up to you. As long as you can undo and redo it.
textBox1.Undo();textBox3.Redo();
import org.eclipse.swt.SWT;import org.eclipse.swt.events.SelectionAdapter;import org.eclipse.swt.events.SelectionEvent;import org.eclipse.swt.graphics.Color;import org.eclipse.swt.graphics.Font;import org.eclipse.swt.graphics.FontData;import org.eclipse.swt.graphics.Image;import org.eclipse.swt.graphics.RGB;import org.eclipse.swt.layout.FillLayout;import org.eclipse.swt.widgets.Button;import org.eclipse.swt.widgets.Display;import org.eclipse.swt.widgets.FontDialog;import org.eclipse.swt.widgets.Shell;import org.eclipse.swt.widgets.Text;
http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/undo/package-summary.htmlThis looks as easy as in .NET:Code: [Select]textBox1.Undo();textBox3.Redo();While trying to implement a Font Dialog, I came across an automatic Font Dialog, but it needs to import stuff like:Code: [Select]import org.eclipse.swt.SWT;import org.eclipse.swt.events.SelectionAdapter;import org.eclipse.swt.events.SelectionEvent;import org.eclipse.swt.graphics.Color;import org.eclipse.swt.graphics.Font;import org.eclipse.swt.graphics.FontData;import org.eclipse.swt.graphics.Image;import org.eclipse.swt.graphics.RGB;import org.eclipse.swt.layout.FillLayout;import org.eclipse.swt.widgets.Button;import org.eclipse.swt.widgets.Display;import org.eclipse.swt.widgets.FontDialog;import org.eclipse.swt.widgets.Shell;import org.eclipse.swt.widgets.Text;Both NetBeans and Eclipse say that those imports are invalid. Is it a special download?
Nice, it gets smaller. For the black background mode you should make the cursor white, though.
Oh ok, I thought you could maybe edit it.