home *** CD-ROM | disk | FTP | other *** search
- import java.awt.BorderLayout;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.Event;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.Insets;
- import java.awt.Panel;
- import java.awt.Rectangle;
- import java.awt.Scrollbar;
- import java.awt.TextArea;
- import java.awt.image.ImageObserver;
- import java.util.Date;
- import java.util.StringTokenizer;
- import java.util.Vector;
-
- public class JDPRichText extends Panel {
- static boolean activated = true;
- JDPUser user;
- Scrollbar scrollEast;
- Scrollbar scrollSouth;
- Image offscreen;
- Rectangle offscreensize;
- // $FF: renamed from: gr java.awt.Graphics
- Graphics field_0;
- TextArea text;
- int[] startPos;
- int[] length;
- Font[] font;
- Color[] color;
- String clipBoard = "";
- int selectedFrom;
- int selectedTo;
- int cursorPos;
- int prevCursorPos;
- int initcursorPos;
- int lastpos;
- int lastevtx;
- int lastevty;
- int cursorPosActual = -1;
- int cursorPosLine = -1;
- int selectFromActual = -1;
- int selectFromLine = -1;
- int selectToActual = -1;
- int selectToLine = -1;
- byte[] docText = new byte[102400];
- int[] widths;
- int maxWidth;
- int maxLineWidth;
- Vector byteLine;
- int[] lineWidths;
- int[] lineIndex;
- int[] lineMousePos;
- int lineCount;
- int linesSoFar;
- int thisLine;
- int currXpos;
- int currYpos;
- int cursorXpos;
- int cursorYpos;
- int cursorFontHeight;
- int indent;
- int indentWidth = 4;
- int tabWidth = 28;
- int rightIndent = 10;
- int southOffset;
- int lastXpos;
- int lastYpos;
- boolean wrapOn = true;
- boolean beyondRightBorder;
- Rectangle Bounds;
- Date timenow;
- long lastredraw;
- // $FF: renamed from: fm java.awt.FontMetrics
- FontMetrics field_1;
- Font lastFont;
- boolean nothingChanged;
- boolean dropEvent;
- Color textHighlightText;
- Color textHighlight;
-
- public void setText(String var1) {
- this.init();
- if (var1 == null) {
- var1 = "";
- }
-
- this.text.setText(var1);
- this.formatText();
- this.nothingChanged = false;
- ((Component)this).repaint();
- }
-
- public String getText() {
- return this.text.getText();
- }
-
- public int getSelectionEnd() {
- return this.selectedTo;
- }
-
- public JDPRichText() {
- activated = JDPUser.classactivated;
- if (!activated) {
- System.out.println("Software Violation - this class may only be used in conjunction with JDesignerPro.");
- } else {
- this.textHighlightText = JDPUtils.getTextHighlightText();
- this.textHighlight = JDPUtils.getTextHighlight();
- this.text = new TextArea();
- this.text.setBackground(Color.white);
- this.text.setForeground(Color.black);
- this.init();
- ((Container)this).setLayout(new BorderLayout());
- this.byteLine = new Vector(10, 10);
- this.lineWidths = new int[10000];
- this.lineIndex = new int[10000];
- this.lineMousePos = new int[10000];
- this.startPos = new int[1];
- this.startPos[0] = 0;
- }
- }
-
- public JDPRichText(JDPUser var1) {
- activated = JDPUser.classactivated;
- if (!activated) {
- System.out.println("Software Violation - this class may only be used in conjunction with JDesignerPro.");
- } else {
- this.user = var1;
- this.text = new TextArea();
- this.text.setBackground(Color.white);
- this.text.setForeground(Color.black);
- this.init();
- ((Container)this).setLayout(new BorderLayout());
- this.byteLine = new Vector(10, 10);
- this.lineWidths = new int[10000];
- this.lineIndex = new int[10000];
- this.lineMousePos = new int[10000];
- this.startPos = new int[1];
- this.startPos[0] = 0;
- }
- }
-
- public void setPostitions(int[] var1) {
- this.startPos = var1;
- this.nothingChanged = false;
- ((Component)this).repaint();
- }
-
- public void select(int var1, int var2) {
- this.selectedFrom = var1;
- this.selectedTo = var2;
- this.nothingChanged = false;
- ((Component)this).repaint();
- }
-
- public void setWrap(boolean var1) {
- this.wrapOn = var1;
- ((Component)this).repaint();
- }
-
- public boolean getWrap() {
- return this.wrapOn;
- }
-
- public synchronized void update(Graphics var1) {
- Rectangle var2 = ((Component)this).getParent().getParent().bounds();
- if (this.Bounds == null || var2.width != this.Bounds.width || var2.height != this.Bounds.height) {
- this.nothingChanged = false;
- }
-
- if (this.nothingChanged && this.offscreen != null) {
- var1.drawImage(this.offscreen, 0, 0, (ImageObserver)null);
- } else {
- this.nothingChanged = true;
- this.Bounds = ((Component)this).bounds();
- if (this.Bounds.width > 0 && this.Bounds.height > 0) {
- if (this.offscreen == null || this.Bounds.width != this.offscreensize.width || this.Bounds.height != this.offscreensize.height) {
- this.offscreen = ((Component)this).createImage(this.Bounds.width, this.Bounds.height);
- this.offscreensize = this.Bounds;
- this.field_0 = this.offscreen.getGraphics();
- this.field_0.setFont(((Component)this).getFont());
- }
-
- if (this.font == null) {
- this.field_0.setFont(((Component)this).getFont());
- } else {
- this.field_0.setFont(this.font[0]);
- }
-
- this.field_1 = this.field_0.getFontMetrics();
- this.widths = this.field_1.getWidths();
- this.widths[9] = this.tabWidth;
- this.lastFont = this.field_0.getFont();
- Color var3 = this.getBackground();
- int var4 = this.field_1.getHeight();
- int var5 = var4;
- if (this.lastXpos < 0) {
- this.lastXpos = 0;
- }
-
- if (this.lastYpos < 0) {
- this.lastYpos = 0;
- }
-
- this.currYpos = -this.lastYpos + var4;
- this.currXpos = -this.lastXpos + this.indent + this.indentWidth;
- int var6 = 0;
- int var7 = this.lastYpos;
- this.field_0.setColor(this.text.getBackground());
- this.field_0.fillRect(0, 0, this.Bounds.width, this.Bounds.height);
- if (this.color == null) {
- this.field_0.setColor(this.text.getForeground());
- } else {
- this.field_0.setColor(this.color[0]);
- }
-
- byte var8 = 5;
- if (this.scrollEast != null && this.scrollEast.isVisible()) {
- var8 = 15;
- }
-
- this.maxWidth = this.Bounds.width - var8 - (this.indent + this.indentWidth);
- this.maxLineWidth = 0;
- int var9 = 0;
- int[] var10000 = new int[20];
- var10000 = new int[20];
- boolean var10 = true;
- this.beyondRightBorder = false;
- boolean var11 = false;
- boolean var12 = false;
- String var14 = this.text.getText();
- var14.getBytes(0, var14.length(), this.docText, 0);
- this.lastpos = 0;
- if (this.cursorPos < 0) {
- this.cursorPos = 0;
- }
-
- if (this.selectedFrom < 0) {
- this.selectedFrom = 0;
- }
-
- if (this.selectedTo < 0) {
- this.selectedTo = 0;
- }
-
- if (this.selectedTo > var14.length()) {
- this.selectedTo = var14.length();
- }
-
- if (this.selectedFrom > var14.length()) {
- this.selectedFrom = var14.length();
- }
-
- if (this.cursorPos > var14.length()) {
- this.cursorPos = var14.length();
- }
-
- if (this.cursorPos < this.lastpos) {
- this.lastpos = this.cursorPos - 1;
- }
-
- if (this.lastpos < 0) {
- this.lastpos = 0;
- }
-
- int var15 = -1;
- int var16 = -1;
- this.linesSoFar = 0;
- if (this.wrapOn) {
- this.lastXpos = 0;
- }
-
- for(int var17 = 0; var17 < this.startPos.length; ++var17) {
- int var13;
- if (var17 < this.startPos.length - 1) {
- var13 = this.startPos[var17 + 1];
- } else {
- var13 = var14.length();
- }
-
- if (this.font == null) {
- this.field_0.setFont(((Component)this).getFont());
- } else {
- this.field_0.setFont(this.font[var17]);
- }
-
- if (this.color == null) {
- this.field_0.setColor(this.text.getForeground());
- } else {
- this.field_0.setColor(this.color[var17]);
- }
-
- var12 = true;
- if (this.currXpos < this.indent + this.indentWidth) {
- this.currXpos = this.indent + this.indentWidth;
- }
-
- var9 = this.bytesWidth(this.docText, var6, var13 - var6);
- if (var13 > var6) {
- if (this.field_1.getHeight() != var4 && var10) {
- this.currYpos = this.currYpos + (int)(0.6 * (double)this.field_1.getHeight()) - var4;
- }
-
- var10 = false;
- var4 = this.field_1.getHeight();
-
- for(int var18 = 0; var18 <= this.lineCount; ++var18) {
- this.lineMousePos[this.linesSoFar - (this.lineCount - var18)] = this.currYpos;
- int var19 = 0;
- if (var11) {
- var15 = 0;
- var16 = this.lineWidths[var18];
- }
-
- if (this.selectFromLine == var18) {
- var15 = this.selectFromActual;
- var11 = true;
- var16 = this.lineWidths[var18];
- var19 = this.selectedFrom;
- if (var17 > 0) {
- var19 -= this.startPos[var17];
- }
-
- if (var18 > 0) {
- for(int var20 = 0; var20 < var18; ++var20) {
- var19 -= ((String)this.byteLine.elementAt(var20)).length() + 1;
- }
- }
- }
-
- if (this.selectToLine == var18) {
- var16 = this.selectToActual;
- }
-
- if (var12) {
- if (var14.indexOf("\t") < 0) {
- this.field_0.drawString(((String)this.byteLine.elementAt(var18)).replace('\r', ' '), this.currXpos - this.lastXpos, this.currYpos);
- } else {
- StringTokenizer var31 = new StringTokenizer((String)this.byteLine.elementAt(var18), "\t", true);
- int var21 = this.currXpos;
-
- while(var31.hasMoreTokens()) {
- String var22 = var31.nextToken();
- if (var22.equals("\t")) {
- this.currXpos = this.currXpos - this.indentWidth - this.indent;
- this.currXpos = (this.currXpos / this.tabWidth + 1) * this.tabWidth + this.indentWidth + this.indent;
- } else {
- this.field_0.drawString(var22.replace('\r', ' '), this.currXpos - this.lastXpos, this.currYpos);
- this.currXpos += this.user.u.StringWidth(this.field_0, var22);
- }
- }
-
- this.currXpos = var21;
- }
-
- if (var15 < var16 && var11) {
- Image var32 = ((Component)this).createImage(var16 - var15, var4);
- Graphics var34 = var32.getGraphics();
- var34.setColor(this.textHighlight);
- var34.fillRect(0, 0, var16 - var15, var4);
- if (this.font == null) {
- var34.setFont(((Component)this).getFont());
- } else {
- var34.setFont(this.font[var17]);
- }
-
- var34.setColor(this.textHighlightText);
- if (var19 < 0) {
- var19 = 0;
- }
-
- if (var14.indexOf("\t") < 0) {
- var34.drawString(((String)this.byteLine.elementAt(var18)).substring(var19).replace('\r', ' '), 0, var4 - 4);
- } else {
- StringTokenizer var36 = new StringTokenizer(((String)this.byteLine.elementAt(var18)).substring(var19), "\t", true);
- int var23 = 0;
-
- while(var36.hasMoreTokens()) {
- String var24 = var36.nextToken();
- if (var24.equals("\t")) {
- var23 = ((var23 + this.currXpos + var15) / this.tabWidth + 1) * this.tabWidth - this.currXpos - var15 + 4;
- } else {
- var34.drawString(var24.replace('\r', ' '), var23, var4 - 4);
- var23 += this.user.u.StringWidth(var34, var24);
- }
- }
- }
-
- this.field_0.drawImage(var32, this.currXpos + var15 - this.lastXpos, this.currYpos - var4 + 4, (ImageObserver)null);
- }
- }
-
- if (this.selectToLine == var18) {
- var15 = -1;
- var16 = -1;
- var11 = false;
- }
-
- if (this.cursorPosLine == var18) {
- this.thisLine = this.linesSoFar - (this.lineCount - var18);
- Font var33;
- if (this.font == null) {
- var33 = ((Component)this).getFont();
- } else {
- var33 = this.font[var17];
- }
-
- Font var35 = new Font(var33.getName(), 1, var33.getSize() + 2);
- this.field_0.setFont(var35);
- this.field_0.setColor(this.text.getForeground());
- this.cursorXpos = this.currXpos + this.cursorPosActual - this.lastXpos - 1;
- this.cursorYpos = this.currYpos - var4 + 4;
- this.cursorFontHeight = var4;
- if (this.isEditable()) {
- this.field_0.fillRect(this.cursorXpos, this.cursorYpos, 1, var4);
- }
-
- if (this.font != null) {
- this.field_0.setFont(this.font[var17]);
- } else {
- this.field_0.setFont(((Component)this).getFont());
- }
-
- if (this.color != null) {
- this.field_0.setColor(this.color[var17]);
- } else {
- this.field_0.setColor(this.text.getForeground());
- }
- }
-
- if (this.lineWidths[var18] + this.currXpos > this.maxLineWidth) {
- this.maxLineWidth = this.lineWidths[var18] + this.currXpos;
- }
-
- if (var18 < this.lineCount) {
- this.currYpos += var4;
- this.currXpos = this.indent + this.indentWidth;
- }
- }
-
- int var38 = this.currYpos + var5;
- this.currXpos += var9;
- if (this.cursorPosLine > this.lineCount) {
- this.thisLine = this.linesSoFar;
- Font var29;
- if (this.font == null) {
- var29 = ((Component)this).getFont();
- } else {
- var29 = this.font[var17];
- }
-
- Font var30 = new Font(var29.getName(), 1, var29.getSize() + 2);
- this.field_0.setFont(var30);
- this.field_0.setColor(this.text.getForeground());
- this.cursorXpos = this.indent + this.indentWidth + this.cursorPosActual - this.lastXpos - 1;
- this.cursorYpos = this.currYpos + 4;
- this.cursorFontHeight = var4;
- this.field_0.fillRect(this.cursorXpos, this.cursorYpos, 1, var4);
- if (this.font != null) {
- this.field_0.setFont(this.font[var17]);
- } else {
- this.field_0.setFont(((Component)this).getFont());
- }
-
- if (this.color != null) {
- this.field_0.setColor(this.color[var17]);
- } else {
- this.field_0.setColor(this.text.getForeground());
- }
- }
- }
-
- var6 = var13;
- }
-
- this.currYpos += this.lastYpos;
- if ((this.beyondRightBorder || this.lastXpos != 0) && !this.wrapOn) {
- if (this.scrollSouth == null) {
- this.scrollSouth = new Scrollbar(0, 0, 100, 0, 100);
- ((Container)this).add(this.scrollSouth);
- }
-
- this.scrollSouth.move(2, this.Bounds.height - 14);
- this.scrollSouth.resize(this.Bounds.width - 16, 12);
- this.scrollSouth.show();
- int var27 = 0;
- if (System.getProperty("java.vendor").startsWith("Netscape") && System.getProperty("java.version").compareTo("1.1.5") < 0 || System.getProperty("java.vendor").startsWith("Microsoft") && System.getProperty("java.version").compareTo("1.1.4") < 0) {
- var27 = this.Bounds.width;
- }
-
- this.scrollSouth.setValues(this.lastXpos, this.Bounds.width, 0, this.maxLineWidth - var27);
- this.southOffset = 14;
- } else {
- if (this.scrollSouth != null) {
- this.scrollSouth.hide();
- }
-
- this.southOffset = 0;
- }
-
- if (this.currYpos <= this.Bounds.height && this.lastYpos == 0) {
- if (this.scrollEast != null) {
- this.scrollEast.disable();
- }
- } else {
- if (this.scrollEast == null) {
- this.scrollEast = new Scrollbar(1, 0, 100, 0, 100);
- ((Container)this).add(this.scrollEast);
- }
-
- int var28 = 0;
- if (System.getProperty("java.vendor").startsWith("Netscape") && System.getProperty("java.version").compareTo("1.1.5") < 0 || System.getProperty("java.vendor").startsWith("Microsoft") && System.getProperty("java.version").compareTo("1.1.4") < 0) {
- var28 = this.Bounds.height;
- }
-
- this.scrollEast.setValues(this.lastYpos, this.Bounds.height, 0, this.currYpos + this.southOffset - var28);
- if (this.scrollSouth != null && this.scrollSouth.isVisible()) {
- this.scrollEast.move(this.Bounds.width - 14, 2);
- this.scrollEast.resize(12, this.Bounds.height - 16);
- } else {
- this.scrollEast.move(this.Bounds.width - 14, 2);
- this.scrollEast.resize(12, this.Bounds.height - 4);
- }
- }
-
- if (this.scrollEast != null && this.scrollSouth != null && this.scrollEast.isVisible() && this.scrollSouth.isVisible()) {
- this.field_0.setColor(var3);
- this.field_0.fillRect(this.Bounds.width - 14, this.Bounds.height - 14, 13, 13);
- }
-
- this.field_0.setColor(JDPUtils.darker(var3));
- this.field_0.drawLine(0, 0, this.Bounds.width, 0);
- this.field_0.drawLine(0, 0, 0, this.Bounds.height);
- this.field_0.setColor(Color.black);
- this.field_0.drawLine(1, 1, this.Bounds.width - 1, 1);
- this.field_0.drawLine(1, 1, 1, this.Bounds.height - 1);
- this.field_0.setColor(JDPUtils.brighter(var3));
- this.field_0.drawLine(this.Bounds.width - 1, 0, this.Bounds.width - 1, this.Bounds.height - 1);
- this.field_0.drawLine(0, this.Bounds.height - 1, this.Bounds.width - 1, this.Bounds.height - 1);
- this.field_0.setColor(var3);
- this.field_0.drawLine(this.Bounds.width - 2, 1, this.Bounds.width - 2, this.Bounds.height - 2);
- this.field_0.drawLine(1, this.Bounds.height - 2, this.Bounds.width - 2, this.Bounds.height - 2);
- this.field_0.setColor(Color.black);
- var1.drawImage(this.offscreen, 0, 0, this.Bounds.width, this.Bounds.height, (ImageObserver)null);
- if (this.lineIndex[this.linesSoFar + 1] == 0) {
- this.lineIndex[this.linesSoFar + 1] = var14.length();
- }
-
- }
- }
- }
-
- void adjustCursor(Event var1) {
- if (var1.modifiers == 1) {
- if (this.cursorPos >= this.selectedFrom) {
- this.selectedTo = this.cursorPos;
- } else {
- this.selectedFrom = this.cursorPos;
- }
- } else {
- if (this.selectedFrom < this.selectedTo) {
- this.cursorPos = this.selectedFrom;
- }
-
- this.selectedFrom = this.cursorPos;
- this.selectedTo = this.cursorPos;
- }
-
- this.nothingChanged = false;
- ((Component)this).repaint();
- }
-
- public boolean isEditable() {
- return this.text.isEditable();
- }
-
- public Dimension preferredSize() {
- return this.minimumSize();
- }
-
- public void setFonts(Font[] var1) {
- this.font = var1;
- this.nothingChanged = false;
- ((Component)this).repaint();
- }
-
- public Insets insets() {
- return new Insets(5, 0, 0, 0);
- }
-
- public void layout() {
- ((Component)this).repaint();
- }
-
- void showCursor() {
- if (this.cursorYpos - this.lastYpos - this.cursorFontHeight < 10) {
- this.lastYpos -= this.cursorFontHeight;
- }
-
- if (this.cursorYpos - this.lastYpos + this.cursorFontHeight > this.Bounds.height - 10) {
- this.lastYpos += this.cursorFontHeight;
- }
-
- if (this.cursorPos >= this.lineIndex[this.thisLine + 1]) {
- if (this.cursorYpos + this.cursorFontHeight > this.Bounds.height - 10) {
- this.lastYpos += this.cursorFontHeight;
- }
- } else if (this.cursorPos <= this.lineIndex[this.thisLine] - 1) {
- if (this.cursorYpos - this.cursorFontHeight < 10) {
- this.lastYpos -= this.cursorFontHeight;
- }
- } else if (this.prevCursorPos > 0) {
- String var1 = this.text.getText();
- if (this.cursorPos < var1.length() && this.prevCursorPos < var1.length()) {
- int var2 = 0;
- if (this.cursorPos > 0 && this.cursorPos > this.prevCursorPos) {
- var2 = this.user.u.StringWidth(this.field_0, var1.substring(this.prevCursorPos, this.cursorPos));
- } else {
- var2 = this.user.u.StringWidth(this.field_0, var1.substring(this.cursorPos, this.prevCursorPos));
- }
-
- if (this.lastXpos != -1 && this.cursorXpos + var2 > this.Bounds.width - 20 && this.cursorPos > this.prevCursorPos) {
- this.lastXpos += var2;
- }
-
- if (this.lastXpos != -1 && this.cursorXpos - var2 < 0 && this.cursorPos < this.prevCursorPos) {
- this.lastXpos -= var2;
- }
-
- if (this.lastXpos < 0) {
- this.lastXpos = 0;
- }
- }
- }
-
- this.prevCursorPos = this.cursorPos;
- }
-
- public String getSelectedText() {
- String var1 = this.text.getText();
- return var1.substring(this.selectedFrom, this.selectedTo);
- }
-
- void keyDown(Event var1) {
- String var2 = this.text.getText();
- if (var1.modifiers == 2) {
- switch (var1.key) {
- case 3:
- this.clipBoard = var2.substring(this.selectedFrom, this.selectedTo);
- return;
- case 22:
- String var9 = var2.substring(0, this.selectedFrom) + this.clipBoard + var2.substring(this.selectedTo);
- this.text.setText(var9);
-
- for(int var14 = 0; var14 < this.startPos.length; ++var14) {
- if (this.startPos[var14] > this.cursorPos) {
- int[] var18 = this.startPos;
- var18[var14] += this.clipBoard.length();
- }
- }
-
- this.cursorPos += this.clipBoard.length();
- this.selectedFrom = this.cursorPos;
- this.selectedTo = this.cursorPos;
- this.nothingChanged = false;
- this.formatText();
- ((Component)this).repaint();
- return;
- case 24:
- if (this.selectedFrom < this.selectedTo) {
- this.clipBoard = var2.substring(this.selectedFrom, this.selectedTo);
- this.text.setText(var2.substring(0, this.selectedFrom) + var2.substring(this.selectedTo));
- this.cursorPos = this.selectedFrom;
- }
-
- for(int var13 = 0; var13 < this.startPos.length; ++var13) {
- if (this.startPos[var13] > this.selectedTo) {
- int[] var17 = this.startPos;
- var17[var13] -= this.clipBoard.length();
- }
- }
-
- this.selectedFrom = this.cursorPos;
- this.selectedTo = this.cursorPos;
- this.nothingChanged = false;
- this.formatText();
- ((Component)this).repaint();
- return;
- default:
- }
- } else {
- switch (var1.key) {
- case 8:
- case 127:
- if (this.text.isEditable() && var2.length() > 0 && this.cursorPos >= 0) {
- String var8;
- if (this.selectedFrom == this.selectedTo) {
- if (var1.key == 8) {
- if (this.cursorPos > 0) {
- var8 = var2.substring(0, this.selectedFrom - 1) + var2.substring(this.selectedTo);
- this.cursorPos += -1;
-
- for(int var10 = 0; var10 < this.startPos.length; ++var10) {
- if (this.startPos[var10] > this.cursorPos) {
- int[] var16 = this.startPos;
- var16[var10] += -1;
- }
- }
- } else {
- var8 = var2;
- }
- } else {
- var8 = var2.substring(0, this.selectedFrom);
- if (var2.length() > this.selectedTo) {
- var8 = var8 + var2.substring(this.selectedTo + 1);
- }
-
- for(int var4 = 0; var4 < this.startPos.length; ++var4) {
- if (this.startPos[var4] > this.cursorPos) {
- int[] var10000 = this.startPos;
- var10000[var4] += -1;
- }
- }
- }
- } else {
- var8 = var2.substring(0, this.selectedFrom) + var2.substring(this.selectedTo);
- this.cursorPos = this.selectedFrom;
- }
-
- this.selectedFrom = this.cursorPos;
- this.selectedTo = this.cursorPos;
- this.text.setText(var8);
- if (var1.key == 8) {
- int var11 = this.user.u.StringWidth(this.field_0, var8);
- if (this.lastXpos != -1 && this.cursorXpos < 20) {
- this.lastXpos -= var11;
- }
- }
-
- this.nothingChanged = false;
- this.formatText();
- ((Component)this).repaint();
- }
-
- return;
- case 10:
- this.lastXpos = -1;
- byte var3 = 0;
- if (this.scrollSouth != null && this.scrollSouth.isVisible()) {
- var3 = 14;
- }
-
- if (this.cursorYpos + this.cursorFontHeight > this.Bounds.height - 10 - var3) {
- this.lastYpos += this.cursorFontHeight;
- }
- case 9:
- default:
- if (this.text.isEditable()) {
- char[] var12 = new char[]{(char)var1.key};
- String var5 = new String(new String(var12));
- String var6 = var2.substring(0, this.selectedFrom) + var5 + var2.substring(this.selectedTo);
- if (this.selectedFrom == this.selectedTo) {
- ++this.cursorPos;
- } else {
- this.cursorPos = this.selectedFrom + 1;
- }
-
- this.selectedFrom = this.cursorPos;
- this.selectedTo = this.cursorPos;
- this.text.setText(var6);
-
- for(int var7 = 0; var7 < this.startPos.length; ++var7) {
- if (this.startPos[var7] > this.cursorPos) {
- int var10002 = this.startPos[var7]++;
- }
- }
-
- int var15 = this.user.u.StringWidth(this.field_0, this.text.getText().substring(this.cursorPos - 1, this.cursorPos));
- if (this.lastXpos != -1 && this.cursorXpos + var15 > this.Bounds.width - 20) {
- this.lastXpos += var15;
- }
-
- this.nothingChanged = false;
- this.formatText();
- ((Component)this).repaint();
- }
- }
- }
- }
-
- public void setBackground(Color var1) {
- this.text.setBackground(var1);
- this.nothingChanged = false;
- ((Component)this).repaint();
- }
-
- public Color getBackground() {
- return this.text.getBackground();
- }
-
- public void paint(Graphics var1) {
- this.update(var1);
- }
-
- public void setEditable(boolean var1) {
- this.text.setEditable(var1);
- }
-
- public int getSelectionStart() {
- return this.selectedFrom;
- }
-
- public Dimension minimumSize() {
- Dimension var1 = new Dimension(23, 23);
- return var1;
- }
-
- int bytesWidth(byte[] var1, int var2, int var3) {
- this.lineCount = -1;
- this.byteLine = new Vector(10, 50);
- int var4 = 0;
- int var5 = var2;
- int var7 = 0;
- int var8 = this.currXpos;
- boolean var9 = false;
- this.cursorPosActual = -1;
- this.cursorPosLine = -1;
- this.selectFromActual = -1;
- this.selectFromLine = -1;
- this.selectToActual = -1;
- this.selectToLine = -1;
- if (this.field_0.getFont() != this.lastFont) {
- this.field_1 = this.field_0.getFontMetrics();
- this.widths = this.field_1.getWidths();
- this.widths[9] = this.tabWidth;
- this.lastFont = this.field_0.getFont();
- }
-
- this.lineIndex[0] = 0;
-
- int var6;
- for(var6 = 0; var6 < var3; ++var6) {
- byte var10 = var1[var2 + var6];
- if (this.cursorPos == var6 + var2) {
- this.cursorPosActual = var4;
- this.cursorPosLine = this.lineCount + 1;
- }
-
- if (this.selectedFrom == var6 + var2) {
- this.selectFromActual = var4;
- this.selectFromLine = this.lineCount + 1;
- }
-
- if (this.selectedTo == var6 + var2) {
- this.selectToActual = var4;
- this.selectToLine = this.lineCount + 1;
- }
-
- if (var10 == 10) {
- this.byteLine.addElement(new String(var1, 0, var5, var2 + var6 - var5));
- ++this.lineCount;
- var5 = var2 + var6 + 1;
- this.lineIndex[++this.linesSoFar] = var5;
- this.lineWidths[this.lineCount] = var4;
- var4 = 0;
- var7 = var6 + 1;
- var8 = this.indent + this.indentWidth;
- } else if (var10 != 13) {
- if (var10 == 9) {
- var4 = ((var4 + (var8 - this.indent - this.indentWidth)) / this.tabWidth + 1) * this.tabWidth - (var8 - this.indent - this.indentWidth);
- } else if (var10 >= 0) {
- var4 += this.widths[var10];
- }
- }
-
- if (this.wrapOn && var4 > this.maxWidth - (var8 - this.indent - this.indentWidth) - this.rightIndent) {
- int var11 = var2 + var6;
-
- for(this.lineWidths[this.lineCount + 1] = var4; var11 > var5 && var1[var11] != 32 && var1[var11] != 9; --var11) {
- this.lineWidths[this.lineCount + 1] = var4 - this.widths[var1[var11]];
- }
-
- if (var11 == var5) {
- this.byteLine.addElement(new String(var1, 0, var5, var2 + var6 - var5));
- ++this.lineCount;
- this.lineIndex[++this.linesSoFar] = var2 + var6 + 1;
- } else {
- this.byteLine.addElement(new String(var1, 0, var5, var11 - var5));
- ++this.lineCount;
-
- for(this.lineIndex[++this.linesSoFar] = var11 + 1; var11 < var2 + var3 && (var1[var11] == 32 || var1[var11] == 9); ++var11) {
- }
-
- var6 = var11 - var2;
- }
-
- var5 = var2 + var6;
- var4 = this.widths[var1[var5]];
- var7 = var6;
- var8 = this.indent + this.indentWidth;
- var9 = true;
- } else if (!this.wrapOn && var4 > this.maxWidth - 5 - (var8 - this.indent - this.indentWidth) - this.rightIndent) {
- this.beyondRightBorder = true;
- }
- }
-
- if (this.cursorPosLine == -1 && this.cursorPos == var6 + var2) {
- this.cursorPosActual = var4;
- this.cursorPosLine = this.lineCount + 1;
- }
-
- if (var6 - var7 >= 0) {
- this.byteLine.addElement(new String(var1, 0, var5, var6 - var7));
- ++this.lineCount;
- this.lineIndex[this.linesSoFar + 1] = var2 + var6 + 1;
- this.lineWidths[this.lineCount] = var4;
- }
-
- return var4;
- }
-
- public void setColors(Color[] var1) {
- this.color = var1;
- this.nothingChanged = false;
- ((Component)this).repaint();
- }
-
- public void init() {
- this.cursorPos = 0;
- this.prevCursorPos = 0;
- this.initcursorPos = 0;
- this.lastpos = 0;
- this.lastevtx = 0;
- this.lastevty = 0;
- this.cursorPosActual = -1;
- this.cursorPosLine = -1;
- this.selectFromActual = -1;
- this.selectFromLine = -1;
- this.selectToActual = -1;
- this.selectToLine = -1;
- this.linesSoFar = 0;
- this.thisLine = 0;
- this.currXpos = 0;
- this.currYpos = 0;
- this.cursorXpos = 0;
- this.cursorYpos = 0;
- this.southOffset = 0;
- this.lastXpos = 0;
- this.lastYpos = 0;
- this.beyondRightBorder = false;
- }
-
- public void setForeground(Color var1) {
- this.text.setForeground(var1);
- this.nothingChanged = false;
- ((Component)this).repaint();
- }
-
- public Color getForeground() {
- return this.text.getForeground();
- }
-
- public synchronized boolean handleEvent(Event var1) {
- int var2 = this.lastYpos;
- int var3 = this.lastXpos;
- if (this.scrollEast != null && var1.target.equals(this.scrollEast)) {
- ((Component)this).requestFocus();
- this.nothingChanged = false;
- switch (var1.id) {
- case 601:
- this.dropEvent = true;
- this.lastYpos -= 20;
- if (var2 != this.lastYpos) {
- ((Component)this).repaint();
- }
-
- return true;
- case 602:
- this.dropEvent = true;
- this.lastYpos += 20;
- if (this.lastYpos > this.currYpos - this.Bounds.height + 14) {
- this.lastYpos = this.currYpos - this.Bounds.height + 10 + 14;
- }
-
- if (var2 != this.lastYpos) {
- ((Component)this).repaint();
- }
-
- return true;
- case 603:
- this.dropEvent = true;
- this.lastYpos = this.lastYpos - this.Bounds.height + 20;
- if (this.lastYpos < 0) {
- this.lastYpos = 0;
- }
-
- if (var2 != this.lastYpos) {
- ((Component)this).repaint();
- }
-
- return true;
- case 604:
- this.dropEvent = true;
- this.lastYpos = this.lastYpos + this.Bounds.height - 20;
- if (this.lastYpos > this.currYpos - this.Bounds.height + 14) {
- this.lastYpos = this.currYpos - this.Bounds.height + 10 + 14;
- }
-
- if (var2 != this.lastYpos) {
- ((Component)this).repaint();
- }
-
- return true;
- case 605:
- if (this.dropEvent) {
- this.dropEvent = false;
- return true;
- }
-
- this.lastYpos = this.scrollEast.getValue();
- if (this.lastYpos > this.currYpos - this.Bounds.height + 14) {
- this.lastYpos = this.currYpos - this.Bounds.height + 10 + 14;
- }
-
- if (var2 != this.lastYpos) {
- ((Component)this).repaint();
- }
-
- return true;
- }
- }
-
- if (this.scrollSouth != null && var1.target.equals(this.scrollSouth)) {
- ((Component)this).requestFocus();
- this.nothingChanged = false;
- switch (var1.id) {
- case 601:
- this.dropEvent = true;
- this.lastXpos -= 20;
- if (var3 != this.lastXpos) {
- ((Component)this).repaint();
- }
-
- return true;
- case 602:
- this.dropEvent = true;
- this.lastXpos += 20;
- if (this.lastXpos > this.maxLineWidth - this.Bounds.width + this.southOffset) {
- this.lastXpos = this.maxLineWidth - this.Bounds.width + 10 + this.southOffset;
- }
-
- if (var3 != this.lastXpos) {
- ((Component)this).repaint();
- }
-
- return true;
- case 603:
- this.dropEvent = true;
- this.lastXpos = this.lastXpos - this.Bounds.width + 20;
- if (this.lastXpos < 0) {
- this.lastXpos = 0;
- }
-
- if (var3 != this.lastXpos) {
- ((Component)this).repaint();
- }
-
- return true;
- case 604:
- this.dropEvent = true;
- this.lastXpos = this.lastXpos + this.Bounds.width - 20;
- if (this.lastXpos > this.maxLineWidth - this.Bounds.width + this.southOffset) {
- this.lastXpos = this.maxLineWidth - this.Bounds.width + 10 + this.southOffset;
- }
-
- if (var3 != this.lastXpos) {
- ((Component)this).repaint();
- }
-
- return true;
- case 605:
- if (this.dropEvent) {
- this.dropEvent = false;
- return true;
- }
-
- this.lastXpos = this.scrollSouth.getValue();
- if (this.lastXpos > this.maxLineWidth - this.Bounds.width + this.southOffset) {
- this.lastXpos = this.maxLineWidth - this.Bounds.width + 10 + this.southOffset;
- }
-
- if (var3 != this.lastXpos) {
- ((Component)this).repaint();
- }
-
- return true;
- }
- }
-
- this.dropEvent = false;
- switch (var1.id) {
- case 202:
- case 205:
- ((Component)this).repaint();
- return false;
- case 401:
- if (this.text.isEditable()) {
- this.nothingChanged = false;
- this.keyDown(var1);
- }
-
- return false;
- case 403:
- this.nothingChanged = false;
- switch (var1.key) {
- case 1002:
- this.lastYpos = this.lastYpos - this.Bounds.height + 10;
- if (this.lastYpos < 0) {
- this.lastYpos = 0;
- }
-
- this.nothingChanged = false;
- if (var2 != this.lastYpos) {
- ((Component)this).repaint();
- }
-
- return true;
- case 1003:
- this.lastYpos = this.lastYpos + this.Bounds.height - 10;
- if (this.lastYpos > this.currYpos - this.Bounds.height) {
- this.lastYpos = this.currYpos - this.Bounds.height + 10;
- }
-
- this.nothingChanged = false;
- if (var2 != this.lastYpos) {
- ((Component)this).repaint();
- }
-
- return true;
- case 1004:
- int var16 = this.cursorPos - this.lineIndex[this.thisLine];
- this.thisLine += -1;
- if (this.thisLine < 0) {
- this.thisLine = 0;
- this.cursorPos = 0;
- } else {
- this.cursorPos = this.lineIndex[this.thisLine];
- if (var16 + this.cursorPos >= this.lineIndex[this.thisLine + 1]) {
- this.cursorPos = this.lineIndex[this.thisLine + 1] - 1;
- } else {
- this.cursorPos += var16;
- }
- }
-
- if (this.cursorYpos - this.cursorFontHeight < 10) {
- this.lastYpos -= this.cursorFontHeight;
- }
-
- this.adjustCursor(var1);
- return true;
- case 1005:
- int var15 = this.cursorPos - this.lineIndex[this.thisLine];
- ++this.thisLine;
- if (this.lineIndex[this.thisLine + 1] == 0) {
- this.thisLine += -1;
- this.cursorPos = this.lineIndex[this.thisLine + 1] - 1;
- } else {
- this.cursorPos = this.lineIndex[this.thisLine];
- if (var15 + this.cursorPos > this.lineIndex[this.thisLine + 1]) {
- this.cursorPos = this.lineIndex[this.thisLine + 1];
- } else {
- this.cursorPos += var15;
- }
- }
-
- if (this.cursorYpos + this.cursorFontHeight > this.Bounds.height - 10) {
- this.lastYpos += this.cursorFontHeight;
- }
-
- this.adjustCursor(var1);
- return true;
- case 1006:
- this.cursorPos += -1;
- this.showCursor();
- this.adjustCursor(var1);
- return true;
- case 1007:
- ++this.cursorPos;
- this.showCursor();
- this.adjustCursor(var1);
- return true;
- default:
- return true;
- }
- case 501:
- ((Component)this).requestFocus();
- int var14 = 0;
- int var17 = 0;
- this.thisLine = 0;
- int var18 = 0;
-
- String var21;
- for(var21 = this.text.getText(); (this.lineMousePos[var18] != 0 || this.lineMousePos[var18 + 1] != 0) && this.lineMousePos[var18] < var1.y - 4; ++var18) {
- if (var17 < this.lineIndex[this.thisLine + 1]) {
- var17 = this.lineIndex[this.thisLine + 1];
- ++this.thisLine;
- }
- }
-
- if (this.lineIndex[this.thisLine] > var21.length()) {
- this.cursorPos = var21.length();
- } else {
- int var8 = this.lineIndex[this.thisLine];
- int var26 = this.lineIndex[this.thisLine + 1] - 1;
- if (var26 < 0) {
- var26 = var21.length();
- }
-
- if (var8 >= 0 && var26 >= 0) {
- var21 = this.text.getText();
- var21 = var21.substring(var8, var26);
- } else {
- var21 = "";
- }
-
- int var27;
- for(var27 = 0; var27 < this.startPos.length && this.startPos[var27] < var8 + this.lastpos; ++var27) {
- }
-
- --var27;
- if (var27 < 0) {
- var27 = 0;
- }
-
- if (this.font == null) {
- this.field_0.setFont(((Component)this).getFont());
- } else {
- this.field_0.setFont(this.font[var27]);
- }
-
- int var29 = 0;
-
- while(var21.length() > this.lastpos + var14 && var29 < var1.x - this.indent - this.indentWidth + this.lastXpos) {
- ++var14;
- if (this.lastpos + var14 > 0) {
- if (var21.substring(this.lastpos + var14 - 1, this.lastpos + var14).equals("\t")) {
- var29 = (var29 / this.tabWidth + 1) * this.tabWidth;
- } else {
- var29 += this.user.u.StringWidth(this.field_0, var21.substring(this.lastpos + var14 - 1, this.lastpos + var14));
- }
- }
-
- if (var27 < this.startPos.length - 1 && var8 + this.lastpos + var14 == this.startPos[var27 + 1]) {
- ++var27;
- if (this.font == null) {
- this.field_0.setFont(((Component)this).getFont());
- } else {
- this.field_0.setFont(this.font[var27]);
- }
- }
- }
-
- this.cursorPos = var17 + this.lastpos + var14;
- }
-
- this.prevCursorPos = this.cursorPos;
- int var24 = this.lastYpos;
- this.showCursor();
- this.lastYpos = var24;
- this.selectedFrom = this.cursorPos;
- this.selectedTo = this.cursorPos;
- this.initcursorPos = this.cursorPos;
- this.nothingChanged = false;
- ((Component)this).repaint();
- return true;
- case 505:
- if (this.user.jdpMainWindow != null) {
- if (this.user.jdpMainWindow.getCursorType() == 3) {
- return false;
- }
-
- if (var1.target.equals(this)) {
- this.user.jdpMainWindow.setCursor(0);
- return true;
- }
- }
-
- return true;
- case 506:
- this.nothingChanged = false;
- this.lastevty = var1.y;
- this.lastevtx = var1.x;
- int var4 = 0;
- String var7 = this.text.getText();
- int var5 = 0;
- this.thisLine = 0;
- int var6 = 0;
-
- for(boolean var9 = false; (this.lineMousePos[var6] != 0 || this.lineMousePos[var6 + 1] != 0) && this.lineMousePos[var6] < var1.y - 4; ++var6) {
- if (var5 < this.lineIndex[this.thisLine + 1]) {
- var5 = this.lineIndex[this.thisLine + 1];
- ++this.thisLine;
- }
- }
-
- int var25;
- if (this.lineIndex[this.thisLine] > var7.length()) {
- var25 = var7.length();
- } else {
- int var10 = this.lineIndex[this.thisLine];
- int var11 = this.lineIndex[this.thisLine + 1] - 1;
- if (var11 < 0) {
- var11 = var7.length();
- }
-
- if (var10 >= 0 && var11 >= 0) {
- var7 = this.text.getText();
- var7 = var7.substring(var10, var11);
- } else {
- var7 = "";
- }
-
- int var12;
- for(var12 = 0; var12 < this.startPos.length && this.startPos[var12] < var10 + this.lastpos; ++var12) {
- }
-
- --var12;
- if (var12 < 0) {
- var12 = 0;
- }
-
- if (this.font == null) {
- this.field_0.setFont(((Component)this).getFont());
- } else {
- this.field_0.setFont(this.font[var12]);
- }
-
- int var13 = 0;
-
- while(var7.length() > this.lastpos + var4 && var13 < var1.x - this.indent - this.indentWidth + this.lastXpos) {
- ++var4;
- if (this.lastpos + var4 > 0) {
- if (var7.substring(this.lastpos + var4 - 1, this.lastpos + var4).equals("\t")) {
- var13 = (var13 / this.tabWidth + 1) * this.tabWidth;
- } else {
- var13 += this.user.u.StringWidth(this.field_0, var7.substring(this.lastpos + var4 - 1, this.lastpos + var4));
- }
- }
-
- if (var12 < this.startPos.length - 1 && var10 + this.lastpos + var4 == this.startPos[var12 + 1]) {
- ++var12;
- if (this.font == null) {
- this.field_0.setFont(((Component)this).getFont());
- } else {
- this.field_0.setFont(this.font[var12]);
- }
- }
- }
-
- var25 = var5 + this.lastpos + var4;
- }
-
- if (var25 < 0 && this.cursorPos == 0) {
- if (var1.x < 0 || var1.x > ((Component)this).bounds().width || var1.y < 0 || var1.y > ((Component)this).bounds().height) {
- this.showCursor();
- }
-
- return true;
- } else if (var25 < this.cursorPos) {
- this.cursorPos = var25;
- if (this.cursorPos >= this.selectedFrom) {
- this.selectedTo = this.cursorPos;
- } else {
- this.selectedFrom = this.cursorPos;
- this.selectedTo = this.initcursorPos;
- }
-
- if (var1.x < 0 || var1.x > ((Component)this).bounds().width || var1.y < 0 || var1.y > ((Component)this).bounds().height) {
- this.showCursor();
- }
-
- ((Component)this).repaint();
- return true;
- } else {
- if (var25 > this.cursorPos) {
- this.cursorPos = var25;
- if (this.cursorPos <= this.selectedTo) {
- this.selectedFrom = this.cursorPos;
- } else {
- this.selectedTo = this.cursorPos;
- this.selectedFrom = this.initcursorPos;
- }
-
- if (var1.x < 0 || var1.x > ((Component)this).bounds().width || var1.y < 0 || var1.y > ((Component)this).bounds().height) {
- this.showCursor();
- }
-
- ((Component)this).repaint();
- return true;
- }
-
- return false;
- }
- default:
- if (this.user.jdpMainWindow == null) {
- return false;
- } else if (this.user.jdpMainWindow.getCursorType() == 3) {
- return false;
- } else if (!var1.target.equals(this)) {
- this.user.jdpMainWindow.setCursor(0);
- return true;
- } else {
- if (this.scrollEast != null && this.scrollEast.isVisible() && var1.x > ((Component)this).bounds().width - 16) {
- this.user.jdpMainWindow.setCursor(0);
- } else if (this.scrollSouth != null && this.scrollSouth.isVisible() && var1.y > ((Component)this).bounds().height - 16) {
- this.user.jdpMainWindow.setCursor(0);
- } else {
- this.user.jdpMainWindow.setCursor(2);
- }
-
- return true;
- }
- }
- }
-
- public void replaceText(String var1, int var2, int var3) {
- String var4 = this.text.getText();
- var4 = var4.substring(0, var2) + var1 + var4.substring(var3);
- this.text.setText(var4);
- this.formatText();
- this.select(var2, var2);
- }
-
- public synchronized void formatText() {
- }
- }
-