//----------------------------------------------------------------------
//----------------------------------------------------------------------
//
//		--------------------
//		 Editeur A S C I I:
//		--------------------
//
//----------------------------------------------------------------------
//----------------------------------------------------------------------

import		java.io.*;
import		java.awt.*;
import		java.awt.event.*;

//----------------------------------------------------------------------
//----------------------------------------------------------------------

/**
 *	Editeur simple de fichiers textes.
 */
public
class		Editor			extends		TextArea
	{
// debut de classe
//----------------------------------------------------------------------

static
Editor		theAppli;

static
void		a			(String s)
	{
	System.out.println(s);
	}

static
boolean		debug			= false;

static
String		fName			= "Editor.java";

public
String		getFName		()
	{
	return	fName;
	}

public
void		setFName		(String p)
	{
	fName = new String(p);
	}

public
void		lecture			()
					throws		Exception
	{
	BufferedReader	theIn	= new BufferedReader
		(new InputStreamReader
		 (new FileInputStream(fName)));

	String	l	= theIn.readLine();
	while	(l != null)
		{
		this.append(l+"\n");
		l	= theIn.readLine();
		}

	
	theIn.close();
	}

public
void		ecriture		()
					throws		Exception
	{
	PrintStream	theOut	= new PrintStream
		(new BufferedOutputStream
		 (new FileOutputStream(fName)));

	theOut.println(this.getText());
	
	theOut.flush();
	theOut.close();
	}

static
public
void		main			(String[] args)
					throws		Exception
	{
	a(" ");
	a("--------------------------------");
	a(" Petit editeur de textes ascii: ");
	a("--------------------------------");

	a("\nB.M.G. version 2014 Hiver ");
	a("\nligne de commande: [-debug][-file=..] ");
	for	(int w = 0; w < args.length; w++)
		{
		a("\t"+w+"\t"+args[w]+"\n");
		/* */if	(args[w].equals("-debug"))
			{
			debug	= true;
			}
		else if	(args[w].startsWith("-file="))
			{}
		}

	theAppli = new Editor(5, 5);
	theAppli . myGo();
	}

void		myGo			()
					throws		Exception
	{
	Frame	theFrame	= new Frame("test edition de textes");
	Editor	theEditor	= new Editor(20, 20);
	theFrame.add(theEditor);
	theFrame.setSize(400, 400);
	theFrame.validate();
	theFrame.setVisible(true);

	theEditor.lecture();
	theEditor.repaint();
	}

public		
		Editor			(int i20, int j20)
	{
	super(i20, j20);
	}

TextArea	theArea;

//----------------------------------------------------------------------
// fin de classe
	}

//----------------------------------------------------------------------
//----------------------------------------------------------------------
//----------------------------------------------------------------------
//----------------------------------------------------------------------

