Author Topic: JavaTyper - a text editor in Java  (Read 9079 times)

0 Members and 1 Guest are viewing this topic.

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: JavaTyper - a text editor in Java
« Reply #15 on: December 23, 2010, 02:32:57 pm »
I 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.

Offline shrear

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 193
  • Rating: +17/-0
    • View Profile
Re: JavaTyper - a text editor in Java
« Reply #16 on: December 23, 2010, 03:02:53 pm »
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...
« Last Edit: December 23, 2010, 03:05:01 pm by shrear »

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: JavaTyper - a text editor in Java
« Reply #17 on: December 23, 2010, 03:41:21 pm »
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...


Some irony, hein?

Next version will have an option to choose the size, I'm already making it. For now, I only added it to 12, quick update :).

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: JavaTyper - a text editor in Java
« Reply #18 on: December 24, 2010, 02:13:32 pm »
I 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.

this is exactly what i do for my tilemap editor. i can give the method for manipulating the stacks if you want, scout. though it may be better to learn about the package javax.swing.undo, because it was built for redo/undo in things like a text editor. my tilemap editor is really simple because you can only undo or redo placing a tile. in a text editor it's probably more complex.


Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: JavaTyper - a text editor in Java
« Reply #19 on: December 24, 2010, 02:18:18 pm »
http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/undo/package-summary.html

This 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?

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: JavaTyper - a text editor in Java
« Reply #20 on: December 24, 2010, 02:19:46 pm »
http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/undo/package-summary.html

This 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?

why do you need all those classes? and yes they seem like a package you would download from the internet for extended usability of Eclipse.


Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: JavaTyper - a text editor in Java
« Reply #21 on: December 27, 2010, 07:49:40 am »
JavaTyper new version is out!

New Features:
> Change Background to Black or White (meaning changing text color to black or white);
> New Icon for the main frame;
> Small optimizations, like importing only the things I need.

Screenshots:
>http://img20.imageshack.us/img20/7290/screenshot0001f.png
>http://img830.imageshack.us/img830/1690/screenshot0002p.png
>http://img692.imageshack.us/img692/1913/screenshot0003a.png

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: JavaTyper - a text editor in Java
« Reply #22 on: December 27, 2010, 08:10:40 am »
lol that is my topic on graduation project
Thanks for making my project easier.
Sig wipe!

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: JavaTyper - a text editor in Java
« Reply #23 on: December 27, 2010, 08:42:46 am »
Great, if you need any help I'm willing to help you with code or anything.


Also, I hate releasing two versions in the same day, but this one is just an optimized version of the other one  8)

I am proud to announce that this version is 16.9KB large and the other one was 18.4KB large.  :w00t:



Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: JavaTyper - a text editor in Java
« Reply #24 on: December 27, 2010, 02:25:19 pm »
Sorry for double post, but here's a new version! The first version was 18.4, last was 16.9 and this one is 15.9KB!

« Last Edit: December 27, 2010, 02:25:48 pm by ScoutDavid »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: JavaTyper - a text editor in Java
« Reply #25 on: December 27, 2010, 06:39:48 pm »
Nice, it gets smaller. For the black background mode you should make the cursor white, though.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: JavaTyper - a text editor in Java
« Reply #26 on: December 27, 2010, 06:41:16 pm »
Nice, it gets smaller. For the black background mode you should make the cursor white, though.

I know ??? But don't know how to :S

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: JavaTyper - a text editor in Java
« Reply #27 on: December 27, 2010, 10:24:07 pm »
Oh ok, I thought you could maybe edit it.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: JavaTyper - a text editor in Java
« Reply #28 on: December 31, 2010, 11:57:28 am »
Oh ok, I thought you could maybe edit it.

Sorry, I don't get what you mean :S

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: JavaTyper - a text editor in Java
« Reply #29 on: December 31, 2010, 01:54:51 pm »
i think you can change the cursor (i.e. go from the standard cursor to the hourglass waiting cursor, etc), but i don't think you can actually change the cursor's attributes like color.