home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Java / JDesignerPro / Jdp3_0.exe / data1.cab / Program_Files / JDPRichText.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-04-09  |  16.4 KB  |  1,441 lines

  1. import java.awt.BorderLayout;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.Dimension;
  6. import java.awt.Event;
  7. import java.awt.Font;
  8. import java.awt.FontMetrics;
  9. import java.awt.Graphics;
  10. import java.awt.Image;
  11. import java.awt.Insets;
  12. import java.awt.Panel;
  13. import java.awt.Rectangle;
  14. import java.awt.Scrollbar;
  15. import java.awt.TextArea;
  16. import java.awt.image.ImageObserver;
  17. import java.util.Date;
  18. import java.util.StringTokenizer;
  19. import java.util.Vector;
  20.  
  21. public class JDPRichText extends Panel {
  22.    static boolean activated = true;
  23.    JDPUser user;
  24.    Scrollbar scrollEast;
  25.    Scrollbar scrollSouth;
  26.    Image offscreen;
  27.    Rectangle offscreensize;
  28.    // $FF: renamed from: gr java.awt.Graphics
  29.    Graphics field_0;
  30.    TextArea text;
  31.    int[] startPos;
  32.    int[] length;
  33.    Font[] font;
  34.    Color[] color;
  35.    String clipBoard = "";
  36.    int selectedFrom;
  37.    int selectedTo;
  38.    int cursorPos;
  39.    int prevCursorPos;
  40.    int initcursorPos;
  41.    int lastpos;
  42.    int lastevtx;
  43.    int lastevty;
  44.    int cursorPosActual = -1;
  45.    int cursorPosLine = -1;
  46.    int selectFromActual = -1;
  47.    int selectFromLine = -1;
  48.    int selectToActual = -1;
  49.    int selectToLine = -1;
  50.    byte[] docText = new byte[102400];
  51.    int[] widths;
  52.    int maxWidth;
  53.    int maxLineWidth;
  54.    Vector byteLine;
  55.    int[] lineWidths;
  56.    int[] lineIndex;
  57.    int[] lineMousePos;
  58.    int lineCount;
  59.    int linesSoFar;
  60.    int thisLine;
  61.    int currXpos;
  62.    int currYpos;
  63.    int cursorXpos;
  64.    int cursorYpos;
  65.    int cursorFontHeight;
  66.    int indent;
  67.    int indentWidth = 4;
  68.    int tabWidth = 28;
  69.    int rightIndent = 10;
  70.    int southOffset;
  71.    int lastXpos;
  72.    int lastYpos;
  73.    boolean wrapOn = true;
  74.    boolean beyondRightBorder;
  75.    Rectangle Bounds;
  76.    Date timenow;
  77.    long lastredraw;
  78.    // $FF: renamed from: fm java.awt.FontMetrics
  79.    FontMetrics field_1;
  80.    Font lastFont;
  81.    boolean nothingChanged;
  82.    boolean dropEvent;
  83.    Color textHighlightText;
  84.    Color textHighlight;
  85.  
  86.    public void setText(String var1) {
  87.       this.init();
  88.       if (var1 == null) {
  89.          var1 = "";
  90.       }
  91.  
  92.       this.text.setText(var1);
  93.       this.formatText();
  94.       this.nothingChanged = false;
  95.       ((Component)this).repaint();
  96.    }
  97.  
  98.    public String getText() {
  99.       return this.text.getText();
  100.    }
  101.  
  102.    public int getSelectionEnd() {
  103.       return this.selectedTo;
  104.    }
  105.  
  106.    public JDPRichText() {
  107.       activated = JDPUser.classactivated;
  108.       if (!activated) {
  109.          System.out.println("Software Violation - this class may only be used in conjunction with JDesignerPro.");
  110.       } else {
  111.          this.textHighlightText = JDPUtils.getTextHighlightText();
  112.          this.textHighlight = JDPUtils.getTextHighlight();
  113.          this.text = new TextArea();
  114.          this.text.setBackground(Color.white);
  115.          this.text.setForeground(Color.black);
  116.          this.init();
  117.          ((Container)this).setLayout(new BorderLayout());
  118.          this.byteLine = new Vector(10, 10);
  119.          this.lineWidths = new int[10000];
  120.          this.lineIndex = new int[10000];
  121.          this.lineMousePos = new int[10000];
  122.          this.startPos = new int[1];
  123.          this.startPos[0] = 0;
  124.       }
  125.    }
  126.  
  127.    public JDPRichText(JDPUser var1) {
  128.       activated = JDPUser.classactivated;
  129.       if (!activated) {
  130.          System.out.println("Software Violation - this class may only be used in conjunction with JDesignerPro.");
  131.       } else {
  132.          this.user = var1;
  133.          this.text = new TextArea();
  134.          this.text.setBackground(Color.white);
  135.          this.text.setForeground(Color.black);
  136.          this.init();
  137.          ((Container)this).setLayout(new BorderLayout());
  138.          this.byteLine = new Vector(10, 10);
  139.          this.lineWidths = new int[10000];
  140.          this.lineIndex = new int[10000];
  141.          this.lineMousePos = new int[10000];
  142.          this.startPos = new int[1];
  143.          this.startPos[0] = 0;
  144.       }
  145.    }
  146.  
  147.    public void setPostitions(int[] var1) {
  148.       this.startPos = var1;
  149.       this.nothingChanged = false;
  150.       ((Component)this).repaint();
  151.    }
  152.  
  153.    public void select(int var1, int var2) {
  154.       this.selectedFrom = var1;
  155.       this.selectedTo = var2;
  156.       this.nothingChanged = false;
  157.       ((Component)this).repaint();
  158.    }
  159.  
  160.    public void setWrap(boolean var1) {
  161.       this.wrapOn = var1;
  162.       ((Component)this).repaint();
  163.    }
  164.  
  165.    public boolean getWrap() {
  166.       return this.wrapOn;
  167.    }
  168.  
  169.    public synchronized void update(Graphics var1) {
  170.       Rectangle var2 = ((Component)this).getParent().getParent().bounds();
  171.       if (this.Bounds == null || var2.width != this.Bounds.width || var2.height != this.Bounds.height) {
  172.          this.nothingChanged = false;
  173.       }
  174.  
  175.       if (this.nothingChanged && this.offscreen != null) {
  176.          var1.drawImage(this.offscreen, 0, 0, (ImageObserver)null);
  177.       } else {
  178.          this.nothingChanged = true;
  179.          this.Bounds = ((Component)this).bounds();
  180.          if (this.Bounds.width > 0 && this.Bounds.height > 0) {
  181.             if (this.offscreen == null || this.Bounds.width != this.offscreensize.width || this.Bounds.height != this.offscreensize.height) {
  182.                this.offscreen = ((Component)this).createImage(this.Bounds.width, this.Bounds.height);
  183.                this.offscreensize = this.Bounds;
  184.                this.field_0 = this.offscreen.getGraphics();
  185.                this.field_0.setFont(((Component)this).getFont());
  186.             }
  187.  
  188.             if (this.font == null) {
  189.                this.field_0.setFont(((Component)this).getFont());
  190.             } else {
  191.                this.field_0.setFont(this.font[0]);
  192.             }
  193.  
  194.             this.field_1 = this.field_0.getFontMetrics();
  195.             this.widths = this.field_1.getWidths();
  196.             this.widths[9] = this.tabWidth;
  197.             this.lastFont = this.field_0.getFont();
  198.             Color var3 = this.getBackground();
  199.             int var4 = this.field_1.getHeight();
  200.             int var5 = var4;
  201.             if (this.lastXpos < 0) {
  202.                this.lastXpos = 0;
  203.             }
  204.  
  205.             if (this.lastYpos < 0) {
  206.                this.lastYpos = 0;
  207.             }
  208.  
  209.             this.currYpos = -this.lastYpos + var4;
  210.             this.currXpos = -this.lastXpos + this.indent + this.indentWidth;
  211.             int var6 = 0;
  212.             int var7 = this.lastYpos;
  213.             this.field_0.setColor(this.text.getBackground());
  214.             this.field_0.fillRect(0, 0, this.Bounds.width, this.Bounds.height);
  215.             if (this.color == null) {
  216.                this.field_0.setColor(this.text.getForeground());
  217.             } else {
  218.                this.field_0.setColor(this.color[0]);
  219.             }
  220.  
  221.             byte var8 = 5;
  222.             if (this.scrollEast != null && this.scrollEast.isVisible()) {
  223.                var8 = 15;
  224.             }
  225.  
  226.             this.maxWidth = this.Bounds.width - var8 - (this.indent + this.indentWidth);
  227.             this.maxLineWidth = 0;
  228.             int var9 = 0;
  229.             int[] var10000 = new int[20];
  230.             var10000 = new int[20];
  231.             boolean var10 = true;
  232.             this.beyondRightBorder = false;
  233.             boolean var11 = false;
  234.             boolean var12 = false;
  235.             String var14 = this.text.getText();
  236.             var14.getBytes(0, var14.length(), this.docText, 0);
  237.             this.lastpos = 0;
  238.             if (this.cursorPos < 0) {
  239.                this.cursorPos = 0;
  240.             }
  241.  
  242.             if (this.selectedFrom < 0) {
  243.                this.selectedFrom = 0;
  244.             }
  245.  
  246.             if (this.selectedTo < 0) {
  247.                this.selectedTo = 0;
  248.             }
  249.  
  250.             if (this.selectedTo > var14.length()) {
  251.                this.selectedTo = var14.length();
  252.             }
  253.  
  254.             if (this.selectedFrom > var14.length()) {
  255.                this.selectedFrom = var14.length();
  256.             }
  257.  
  258.             if (this.cursorPos > var14.length()) {
  259.                this.cursorPos = var14.length();
  260.             }
  261.  
  262.             if (this.cursorPos < this.lastpos) {
  263.                this.lastpos = this.cursorPos - 1;
  264.             }
  265.  
  266.             if (this.lastpos < 0) {
  267.                this.lastpos = 0;
  268.             }
  269.  
  270.             int var15 = -1;
  271.             int var16 = -1;
  272.             this.linesSoFar = 0;
  273.             if (this.wrapOn) {
  274.                this.lastXpos = 0;
  275.             }
  276.  
  277.             for(int var17 = 0; var17 < this.startPos.length; ++var17) {
  278.                int var13;
  279.                if (var17 < this.startPos.length - 1) {
  280.                   var13 = this.startPos[var17 + 1];
  281.                } else {
  282.                   var13 = var14.length();
  283.                }
  284.  
  285.                if (this.font == null) {
  286.                   this.field_0.setFont(((Component)this).getFont());
  287.                } else {
  288.                   this.field_0.setFont(this.font[var17]);
  289.                }
  290.  
  291.                if (this.color == null) {
  292.                   this.field_0.setColor(this.text.getForeground());
  293.                } else {
  294.                   this.field_0.setColor(this.color[var17]);
  295.                }
  296.  
  297.                var12 = true;
  298.                if (this.currXpos < this.indent + this.indentWidth) {
  299.                   this.currXpos = this.indent + this.indentWidth;
  300.                }
  301.  
  302.                var9 = this.bytesWidth(this.docText, var6, var13 - var6);
  303.                if (var13 > var6) {
  304.                   if (this.field_1.getHeight() != var4 && var10) {
  305.                      this.currYpos = this.currYpos + (int)(0.6 * (double)this.field_1.getHeight()) - var4;
  306.                   }
  307.  
  308.                   var10 = false;
  309.                   var4 = this.field_1.getHeight();
  310.  
  311.                   for(int var18 = 0; var18 <= this.lineCount; ++var18) {
  312.                      this.lineMousePos[this.linesSoFar - (this.lineCount - var18)] = this.currYpos;
  313.                      int var19 = 0;
  314.                      if (var11) {
  315.                         var15 = 0;
  316.                         var16 = this.lineWidths[var18];
  317.                      }
  318.  
  319.                      if (this.selectFromLine == var18) {
  320.                         var15 = this.selectFromActual;
  321.                         var11 = true;
  322.                         var16 = this.lineWidths[var18];
  323.                         var19 = this.selectedFrom;
  324.                         if (var17 > 0) {
  325.                            var19 -= this.startPos[var17];
  326.                         }
  327.  
  328.                         if (var18 > 0) {
  329.                            for(int var20 = 0; var20 < var18; ++var20) {
  330.                               var19 -= ((String)this.byteLine.elementAt(var20)).length() + 1;
  331.                            }
  332.                         }
  333.                      }
  334.  
  335.                      if (this.selectToLine == var18) {
  336.                         var16 = this.selectToActual;
  337.                      }
  338.  
  339.                      if (var12) {
  340.                         if (var14.indexOf("\t") < 0) {
  341.                            this.field_0.drawString(((String)this.byteLine.elementAt(var18)).replace('\r', ' '), this.currXpos - this.lastXpos, this.currYpos);
  342.                         } else {
  343.                            StringTokenizer var31 = new StringTokenizer((String)this.byteLine.elementAt(var18), "\t", true);
  344.                            int var21 = this.currXpos;
  345.  
  346.                            while(var31.hasMoreTokens()) {
  347.                               String var22 = var31.nextToken();
  348.                               if (var22.equals("\t")) {
  349.                                  this.currXpos = this.currXpos - this.indentWidth - this.indent;
  350.                                  this.currXpos = (this.currXpos / this.tabWidth + 1) * this.tabWidth + this.indentWidth + this.indent;
  351.                               } else {
  352.                                  this.field_0.drawString(var22.replace('\r', ' '), this.currXpos - this.lastXpos, this.currYpos);
  353.                                  this.currXpos += this.user.u.StringWidth(this.field_0, var22);
  354.                               }
  355.                            }
  356.  
  357.                            this.currXpos = var21;
  358.                         }
  359.  
  360.                         if (var15 < var16 && var11) {
  361.                            Image var32 = ((Component)this).createImage(var16 - var15, var4);
  362.                            Graphics var34 = var32.getGraphics();
  363.                            var34.setColor(this.textHighlight);
  364.                            var34.fillRect(0, 0, var16 - var15, var4);
  365.                            if (this.font == null) {
  366.                               var34.setFont(((Component)this).getFont());
  367.                            } else {
  368.                               var34.setFont(this.font[var17]);
  369.                            }
  370.  
  371.                            var34.setColor(this.textHighlightText);
  372.                            if (var19 < 0) {
  373.                               var19 = 0;
  374.                            }
  375.  
  376.                            if (var14.indexOf("\t") < 0) {
  377.                               var34.drawString(((String)this.byteLine.elementAt(var18)).substring(var19).replace('\r', ' '), 0, var4 - 4);
  378.                            } else {
  379.                               StringTokenizer var36 = new StringTokenizer(((String)this.byteLine.elementAt(var18)).substring(var19), "\t", true);
  380.                               int var23 = 0;
  381.  
  382.                               while(var36.hasMoreTokens()) {
  383.                                  String var24 = var36.nextToken();
  384.                                  if (var24.equals("\t")) {
  385.                                     var23 = ((var23 + this.currXpos + var15) / this.tabWidth + 1) * this.tabWidth - this.currXpos - var15 + 4;
  386.                                  } else {
  387.                                     var34.drawString(var24.replace('\r', ' '), var23, var4 - 4);
  388.                                     var23 += this.user.u.StringWidth(var34, var24);
  389.                                  }
  390.                               }
  391.                            }
  392.  
  393.                            this.field_0.drawImage(var32, this.currXpos + var15 - this.lastXpos, this.currYpos - var4 + 4, (ImageObserver)null);
  394.                         }
  395.                      }
  396.  
  397.                      if (this.selectToLine == var18) {
  398.                         var15 = -1;
  399.                         var16 = -1;
  400.                         var11 = false;
  401.                      }
  402.  
  403.                      if (this.cursorPosLine == var18) {
  404.                         this.thisLine = this.linesSoFar - (this.lineCount - var18);
  405.                         Font var33;
  406.                         if (this.font == null) {
  407.                            var33 = ((Component)this).getFont();
  408.                         } else {
  409.                            var33 = this.font[var17];
  410.                         }
  411.  
  412.                         Font var35 = new Font(var33.getName(), 1, var33.getSize() + 2);
  413.                         this.field_0.setFont(var35);
  414.                         this.field_0.setColor(this.text.getForeground());
  415.                         this.cursorXpos = this.currXpos + this.cursorPosActual - this.lastXpos - 1;
  416.                         this.cursorYpos = this.currYpos - var4 + 4;
  417.                         this.cursorFontHeight = var4;
  418.                         if (this.isEditable()) {
  419.                            this.field_0.fillRect(this.cursorXpos, this.cursorYpos, 1, var4);
  420.                         }
  421.  
  422.                         if (this.font != null) {
  423.                            this.field_0.setFont(this.font[var17]);
  424.                         } else {
  425.                            this.field_0.setFont(((Component)this).getFont());
  426.                         }
  427.  
  428.                         if (this.color != null) {
  429.                            this.field_0.setColor(this.color[var17]);
  430.                         } else {
  431.                            this.field_0.setColor(this.text.getForeground());
  432.                         }
  433.                      }
  434.  
  435.                      if (this.lineWidths[var18] + this.currXpos > this.maxLineWidth) {
  436.                         this.maxLineWidth = this.lineWidths[var18] + this.currXpos;
  437.                      }
  438.  
  439.                      if (var18 < this.lineCount) {
  440.                         this.currYpos += var4;
  441.                         this.currXpos = this.indent + this.indentWidth;
  442.                      }
  443.                   }
  444.  
  445.                   int var38 = this.currYpos + var5;
  446.                   this.currXpos += var9;
  447.                   if (this.cursorPosLine > this.lineCount) {
  448.                      this.thisLine = this.linesSoFar;
  449.                      Font var29;
  450.                      if (this.font == null) {
  451.                         var29 = ((Component)this).getFont();
  452.                      } else {
  453.                         var29 = this.font[var17];
  454.                      }
  455.  
  456.                      Font var30 = new Font(var29.getName(), 1, var29.getSize() + 2);
  457.                      this.field_0.setFont(var30);
  458.                      this.field_0.setColor(this.text.getForeground());
  459.                      this.cursorXpos = this.indent + this.indentWidth + this.cursorPosActual - this.lastXpos - 1;
  460.                      this.cursorYpos = this.currYpos + 4;
  461.                      this.cursorFontHeight = var4;
  462.                      this.field_0.fillRect(this.cursorXpos, this.cursorYpos, 1, var4);
  463.                      if (this.font != null) {
  464.                         this.field_0.setFont(this.font[var17]);
  465.                      } else {
  466.                         this.field_0.setFont(((Component)this).getFont());
  467.                      }
  468.  
  469.                      if (this.color != null) {
  470.                         this.field_0.setColor(this.color[var17]);
  471.                      } else {
  472.                         this.field_0.setColor(this.text.getForeground());
  473.                      }
  474.                   }
  475.                }
  476.  
  477.                var6 = var13;
  478.             }
  479.  
  480.             this.currYpos += this.lastYpos;
  481.             if ((this.beyondRightBorder || this.lastXpos != 0) && !this.wrapOn) {
  482.                if (this.scrollSouth == null) {
  483.                   this.scrollSouth = new Scrollbar(0, 0, 100, 0, 100);
  484.                   ((Container)this).add(this.scrollSouth);
  485.                }
  486.  
  487.                this.scrollSouth.move(2, this.Bounds.height - 14);
  488.                this.scrollSouth.resize(this.Bounds.width - 16, 12);
  489.                this.scrollSouth.show();
  490.                int var27 = 0;
  491.                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) {
  492.                   var27 = this.Bounds.width;
  493.                }
  494.  
  495.                this.scrollSouth.setValues(this.lastXpos, this.Bounds.width, 0, this.maxLineWidth - var27);
  496.                this.southOffset = 14;
  497.             } else {
  498.                if (this.scrollSouth != null) {
  499.                   this.scrollSouth.hide();
  500.                }
  501.  
  502.                this.southOffset = 0;
  503.             }
  504.  
  505.             if (this.currYpos <= this.Bounds.height && this.lastYpos == 0) {
  506.                if (this.scrollEast != null) {
  507.                   this.scrollEast.disable();
  508.                }
  509.             } else {
  510.                if (this.scrollEast == null) {
  511.                   this.scrollEast = new Scrollbar(1, 0, 100, 0, 100);
  512.                   ((Container)this).add(this.scrollEast);
  513.                }
  514.  
  515.                int var28 = 0;
  516.                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) {
  517.                   var28 = this.Bounds.height;
  518.                }
  519.  
  520.                this.scrollEast.setValues(this.lastYpos, this.Bounds.height, 0, this.currYpos + this.southOffset - var28);
  521.                if (this.scrollSouth != null && this.scrollSouth.isVisible()) {
  522.                   this.scrollEast.move(this.Bounds.width - 14, 2);
  523.                   this.scrollEast.resize(12, this.Bounds.height - 16);
  524.                } else {
  525.                   this.scrollEast.move(this.Bounds.width - 14, 2);
  526.                   this.scrollEast.resize(12, this.Bounds.height - 4);
  527.                }
  528.             }
  529.  
  530.             if (this.scrollEast != null && this.scrollSouth != null && this.scrollEast.isVisible() && this.scrollSouth.isVisible()) {
  531.                this.field_0.setColor(var3);
  532.                this.field_0.fillRect(this.Bounds.width - 14, this.Bounds.height - 14, 13, 13);
  533.             }
  534.  
  535.             this.field_0.setColor(JDPUtils.darker(var3));
  536.             this.field_0.drawLine(0, 0, this.Bounds.width, 0);
  537.             this.field_0.drawLine(0, 0, 0, this.Bounds.height);
  538.             this.field_0.setColor(Color.black);
  539.             this.field_0.drawLine(1, 1, this.Bounds.width - 1, 1);
  540.             this.field_0.drawLine(1, 1, 1, this.Bounds.height - 1);
  541.             this.field_0.setColor(JDPUtils.brighter(var3));
  542.             this.field_0.drawLine(this.Bounds.width - 1, 0, this.Bounds.width - 1, this.Bounds.height - 1);
  543.             this.field_0.drawLine(0, this.Bounds.height - 1, this.Bounds.width - 1, this.Bounds.height - 1);
  544.             this.field_0.setColor(var3);
  545.             this.field_0.drawLine(this.Bounds.width - 2, 1, this.Bounds.width - 2, this.Bounds.height - 2);
  546.             this.field_0.drawLine(1, this.Bounds.height - 2, this.Bounds.width - 2, this.Bounds.height - 2);
  547.             this.field_0.setColor(Color.black);
  548.             var1.drawImage(this.offscreen, 0, 0, this.Bounds.width, this.Bounds.height, (ImageObserver)null);
  549.             if (this.lineIndex[this.linesSoFar + 1] == 0) {
  550.                this.lineIndex[this.linesSoFar + 1] = var14.length();
  551.             }
  552.  
  553.          }
  554.       }
  555.    }
  556.  
  557.    void adjustCursor(Event var1) {
  558.       if (var1.modifiers == 1) {
  559.          if (this.cursorPos >= this.selectedFrom) {
  560.             this.selectedTo = this.cursorPos;
  561.          } else {
  562.             this.selectedFrom = this.cursorPos;
  563.          }
  564.       } else {
  565.          if (this.selectedFrom < this.selectedTo) {
  566.             this.cursorPos = this.selectedFrom;
  567.          }
  568.  
  569.          this.selectedFrom = this.cursorPos;
  570.          this.selectedTo = this.cursorPos;
  571.       }
  572.  
  573.       this.nothingChanged = false;
  574.       ((Component)this).repaint();
  575.    }
  576.  
  577.    public boolean isEditable() {
  578.       return this.text.isEditable();
  579.    }
  580.  
  581.    public Dimension preferredSize() {
  582.       return this.minimumSize();
  583.    }
  584.  
  585.    public void setFonts(Font[] var1) {
  586.       this.font = var1;
  587.       this.nothingChanged = false;
  588.       ((Component)this).repaint();
  589.    }
  590.  
  591.    public Insets insets() {
  592.       return new Insets(5, 0, 0, 0);
  593.    }
  594.  
  595.    public void layout() {
  596.       ((Component)this).repaint();
  597.    }
  598.  
  599.    void showCursor() {
  600.       if (this.cursorYpos - this.lastYpos - this.cursorFontHeight < 10) {
  601.          this.lastYpos -= this.cursorFontHeight;
  602.       }
  603.  
  604.       if (this.cursorYpos - this.lastYpos + this.cursorFontHeight > this.Bounds.height - 10) {
  605.          this.lastYpos += this.cursorFontHeight;
  606.       }
  607.  
  608.       if (this.cursorPos >= this.lineIndex[this.thisLine + 1]) {
  609.          if (this.cursorYpos + this.cursorFontHeight > this.Bounds.height - 10) {
  610.             this.lastYpos += this.cursorFontHeight;
  611.          }
  612.       } else if (this.cursorPos <= this.lineIndex[this.thisLine] - 1) {
  613.          if (this.cursorYpos - this.cursorFontHeight < 10) {
  614.             this.lastYpos -= this.cursorFontHeight;
  615.          }
  616.       } else if (this.prevCursorPos > 0) {
  617.          String var1 = this.text.getText();
  618.          if (this.cursorPos < var1.length() && this.prevCursorPos < var1.length()) {
  619.             int var2 = 0;
  620.             if (this.cursorPos > 0 && this.cursorPos > this.prevCursorPos) {
  621.                var2 = this.user.u.StringWidth(this.field_0, var1.substring(this.prevCursorPos, this.cursorPos));
  622.             } else {
  623.                var2 = this.user.u.StringWidth(this.field_0, var1.substring(this.cursorPos, this.prevCursorPos));
  624.             }
  625.  
  626.             if (this.lastXpos != -1 && this.cursorXpos + var2 > this.Bounds.width - 20 && this.cursorPos > this.prevCursorPos) {
  627.                this.lastXpos += var2;
  628.             }
  629.  
  630.             if (this.lastXpos != -1 && this.cursorXpos - var2 < 0 && this.cursorPos < this.prevCursorPos) {
  631.                this.lastXpos -= var2;
  632.             }
  633.  
  634.             if (this.lastXpos < 0) {
  635.                this.lastXpos = 0;
  636.             }
  637.          }
  638.       }
  639.  
  640.       this.prevCursorPos = this.cursorPos;
  641.    }
  642.  
  643.    public String getSelectedText() {
  644.       String var1 = this.text.getText();
  645.       return var1.substring(this.selectedFrom, this.selectedTo);
  646.    }
  647.  
  648.    void keyDown(Event var1) {
  649.       String var2 = this.text.getText();
  650.       if (var1.modifiers == 2) {
  651.          switch (var1.key) {
  652.             case 3:
  653.                this.clipBoard = var2.substring(this.selectedFrom, this.selectedTo);
  654.                return;
  655.             case 22:
  656.                String var9 = var2.substring(0, this.selectedFrom) + this.clipBoard + var2.substring(this.selectedTo);
  657.                this.text.setText(var9);
  658.  
  659.                for(int var14 = 0; var14 < this.startPos.length; ++var14) {
  660.                   if (this.startPos[var14] > this.cursorPos) {
  661.                      int[] var18 = this.startPos;
  662.                      var18[var14] += this.clipBoard.length();
  663.                   }
  664.                }
  665.  
  666.                this.cursorPos += this.clipBoard.length();
  667.                this.selectedFrom = this.cursorPos;
  668.                this.selectedTo = this.cursorPos;
  669.                this.nothingChanged = false;
  670.                this.formatText();
  671.                ((Component)this).repaint();
  672.                return;
  673.             case 24:
  674.                if (this.selectedFrom < this.selectedTo) {
  675.                   this.clipBoard = var2.substring(this.selectedFrom, this.selectedTo);
  676.                   this.text.setText(var2.substring(0, this.selectedFrom) + var2.substring(this.selectedTo));
  677.                   this.cursorPos = this.selectedFrom;
  678.                }
  679.  
  680.                for(int var13 = 0; var13 < this.startPos.length; ++var13) {
  681.                   if (this.startPos[var13] > this.selectedTo) {
  682.                      int[] var17 = this.startPos;
  683.                      var17[var13] -= this.clipBoard.length();
  684.                   }
  685.                }
  686.  
  687.                this.selectedFrom = this.cursorPos;
  688.                this.selectedTo = this.cursorPos;
  689.                this.nothingChanged = false;
  690.                this.formatText();
  691.                ((Component)this).repaint();
  692.                return;
  693.             default:
  694.          }
  695.       } else {
  696.          switch (var1.key) {
  697.             case 8:
  698.             case 127:
  699.                if (this.text.isEditable() && var2.length() > 0 && this.cursorPos >= 0) {
  700.                   String var8;
  701.                   if (this.selectedFrom == this.selectedTo) {
  702.                      if (var1.key == 8) {
  703.                         if (this.cursorPos > 0) {
  704.                            var8 = var2.substring(0, this.selectedFrom - 1) + var2.substring(this.selectedTo);
  705.                            this.cursorPos += -1;
  706.  
  707.                            for(int var10 = 0; var10 < this.startPos.length; ++var10) {
  708.                               if (this.startPos[var10] > this.cursorPos) {
  709.                                  int[] var16 = this.startPos;
  710.                                  var16[var10] += -1;
  711.                               }
  712.                            }
  713.                         } else {
  714.                            var8 = var2;
  715.                         }
  716.                      } else {
  717.                         var8 = var2.substring(0, this.selectedFrom);
  718.                         if (var2.length() > this.selectedTo) {
  719.                            var8 = var8 + var2.substring(this.selectedTo + 1);
  720.                         }
  721.  
  722.                         for(int var4 = 0; var4 < this.startPos.length; ++var4) {
  723.                            if (this.startPos[var4] > this.cursorPos) {
  724.                               int[] var10000 = this.startPos;
  725.                               var10000[var4] += -1;
  726.                            }
  727.                         }
  728.                      }
  729.                   } else {
  730.                      var8 = var2.substring(0, this.selectedFrom) + var2.substring(this.selectedTo);
  731.                      this.cursorPos = this.selectedFrom;
  732.                   }
  733.  
  734.                   this.selectedFrom = this.cursorPos;
  735.                   this.selectedTo = this.cursorPos;
  736.                   this.text.setText(var8);
  737.                   if (var1.key == 8) {
  738.                      int var11 = this.user.u.StringWidth(this.field_0, var8);
  739.                      if (this.lastXpos != -1 && this.cursorXpos < 20) {
  740.                         this.lastXpos -= var11;
  741.                      }
  742.                   }
  743.  
  744.                   this.nothingChanged = false;
  745.                   this.formatText();
  746.                   ((Component)this).repaint();
  747.                }
  748.  
  749.                return;
  750.             case 10:
  751.                this.lastXpos = -1;
  752.                byte var3 = 0;
  753.                if (this.scrollSouth != null && this.scrollSouth.isVisible()) {
  754.                   var3 = 14;
  755.                }
  756.  
  757.                if (this.cursorYpos + this.cursorFontHeight > this.Bounds.height - 10 - var3) {
  758.                   this.lastYpos += this.cursorFontHeight;
  759.                }
  760.             case 9:
  761.             default:
  762.                if (this.text.isEditable()) {
  763.                   char[] var12 = new char[]{(char)var1.key};
  764.                   String var5 = new String(new String(var12));
  765.                   String var6 = var2.substring(0, this.selectedFrom) + var5 + var2.substring(this.selectedTo);
  766.                   if (this.selectedFrom == this.selectedTo) {
  767.                      ++this.cursorPos;
  768.                   } else {
  769.                      this.cursorPos = this.selectedFrom + 1;
  770.                   }
  771.  
  772.                   this.selectedFrom = this.cursorPos;
  773.                   this.selectedTo = this.cursorPos;
  774.                   this.text.setText(var6);
  775.  
  776.                   for(int var7 = 0; var7 < this.startPos.length; ++var7) {
  777.                      if (this.startPos[var7] > this.cursorPos) {
  778.                         int var10002 = this.startPos[var7]++;
  779.                      }
  780.                   }
  781.  
  782.                   int var15 = this.user.u.StringWidth(this.field_0, this.text.getText().substring(this.cursorPos - 1, this.cursorPos));
  783.                   if (this.lastXpos != -1 && this.cursorXpos + var15 > this.Bounds.width - 20) {
  784.                      this.lastXpos += var15;
  785.                   }
  786.  
  787.                   this.nothingChanged = false;
  788.                   this.formatText();
  789.                   ((Component)this).repaint();
  790.                }
  791.          }
  792.       }
  793.    }
  794.  
  795.    public void setBackground(Color var1) {
  796.       this.text.setBackground(var1);
  797.       this.nothingChanged = false;
  798.       ((Component)this).repaint();
  799.    }
  800.  
  801.    public Color getBackground() {
  802.       return this.text.getBackground();
  803.    }
  804.  
  805.    public void paint(Graphics var1) {
  806.       this.update(var1);
  807.    }
  808.  
  809.    public void setEditable(boolean var1) {
  810.       this.text.setEditable(var1);
  811.    }
  812.  
  813.    public int getSelectionStart() {
  814.       return this.selectedFrom;
  815.    }
  816.  
  817.    public Dimension minimumSize() {
  818.       Dimension var1 = new Dimension(23, 23);
  819.       return var1;
  820.    }
  821.  
  822.    int bytesWidth(byte[] var1, int var2, int var3) {
  823.       this.lineCount = -1;
  824.       this.byteLine = new Vector(10, 50);
  825.       int var4 = 0;
  826.       int var5 = var2;
  827.       int var7 = 0;
  828.       int var8 = this.currXpos;
  829.       boolean var9 = false;
  830.       this.cursorPosActual = -1;
  831.       this.cursorPosLine = -1;
  832.       this.selectFromActual = -1;
  833.       this.selectFromLine = -1;
  834.       this.selectToActual = -1;
  835.       this.selectToLine = -1;
  836.       if (this.field_0.getFont() != this.lastFont) {
  837.          this.field_1 = this.field_0.getFontMetrics();
  838.          this.widths = this.field_1.getWidths();
  839.          this.widths[9] = this.tabWidth;
  840.          this.lastFont = this.field_0.getFont();
  841.       }
  842.  
  843.       this.lineIndex[0] = 0;
  844.  
  845.       int var6;
  846.       for(var6 = 0; var6 < var3; ++var6) {
  847.          byte var10 = var1[var2 + var6];
  848.          if (this.cursorPos == var6 + var2) {
  849.             this.cursorPosActual = var4;
  850.             this.cursorPosLine = this.lineCount + 1;
  851.          }
  852.  
  853.          if (this.selectedFrom == var6 + var2) {
  854.             this.selectFromActual = var4;
  855.             this.selectFromLine = this.lineCount + 1;
  856.          }
  857.  
  858.          if (this.selectedTo == var6 + var2) {
  859.             this.selectToActual = var4;
  860.             this.selectToLine = this.lineCount + 1;
  861.          }
  862.  
  863.          if (var10 == 10) {
  864.             this.byteLine.addElement(new String(var1, 0, var5, var2 + var6 - var5));
  865.             ++this.lineCount;
  866.             var5 = var2 + var6 + 1;
  867.             this.lineIndex[++this.linesSoFar] = var5;
  868.             this.lineWidths[this.lineCount] = var4;
  869.             var4 = 0;
  870.             var7 = var6 + 1;
  871.             var8 = this.indent + this.indentWidth;
  872.          } else if (var10 != 13) {
  873.             if (var10 == 9) {
  874.                var4 = ((var4 + (var8 - this.indent - this.indentWidth)) / this.tabWidth + 1) * this.tabWidth - (var8 - this.indent - this.indentWidth);
  875.             } else if (var10 >= 0) {
  876.                var4 += this.widths[var10];
  877.             }
  878.          }
  879.  
  880.          if (this.wrapOn && var4 > this.maxWidth - (var8 - this.indent - this.indentWidth) - this.rightIndent) {
  881.             int var11 = var2 + var6;
  882.  
  883.             for(this.lineWidths[this.lineCount + 1] = var4; var11 > var5 && var1[var11] != 32 && var1[var11] != 9; --var11) {
  884.                this.lineWidths[this.lineCount + 1] = var4 - this.widths[var1[var11]];
  885.             }
  886.  
  887.             if (var11 == var5) {
  888.                this.byteLine.addElement(new String(var1, 0, var5, var2 + var6 - var5));
  889.                ++this.lineCount;
  890.                this.lineIndex[++this.linesSoFar] = var2 + var6 + 1;
  891.             } else {
  892.                this.byteLine.addElement(new String(var1, 0, var5, var11 - var5));
  893.                ++this.lineCount;
  894.  
  895.                for(this.lineIndex[++this.linesSoFar] = var11 + 1; var11 < var2 + var3 && (var1[var11] == 32 || var1[var11] == 9); ++var11) {
  896.                }
  897.  
  898.                var6 = var11 - var2;
  899.             }
  900.  
  901.             var5 = var2 + var6;
  902.             var4 = this.widths[var1[var5]];
  903.             var7 = var6;
  904.             var8 = this.indent + this.indentWidth;
  905.             var9 = true;
  906.          } else if (!this.wrapOn && var4 > this.maxWidth - 5 - (var8 - this.indent - this.indentWidth) - this.rightIndent) {
  907.             this.beyondRightBorder = true;
  908.          }
  909.       }
  910.  
  911.       if (this.cursorPosLine == -1 && this.cursorPos == var6 + var2) {
  912.          this.cursorPosActual = var4;
  913.          this.cursorPosLine = this.lineCount + 1;
  914.       }
  915.  
  916.       if (var6 - var7 >= 0) {
  917.          this.byteLine.addElement(new String(var1, 0, var5, var6 - var7));
  918.          ++this.lineCount;
  919.          this.lineIndex[this.linesSoFar + 1] = var2 + var6 + 1;
  920.          this.lineWidths[this.lineCount] = var4;
  921.       }
  922.  
  923.       return var4;
  924.    }
  925.  
  926.    public void setColors(Color[] var1) {
  927.       this.color = var1;
  928.       this.nothingChanged = false;
  929.       ((Component)this).repaint();
  930.    }
  931.  
  932.    public void init() {
  933.       this.cursorPos = 0;
  934.       this.prevCursorPos = 0;
  935.       this.initcursorPos = 0;
  936.       this.lastpos = 0;
  937.       this.lastevtx = 0;
  938.       this.lastevty = 0;
  939.       this.cursorPosActual = -1;
  940.       this.cursorPosLine = -1;
  941.       this.selectFromActual = -1;
  942.       this.selectFromLine = -1;
  943.       this.selectToActual = -1;
  944.       this.selectToLine = -1;
  945.       this.linesSoFar = 0;
  946.       this.thisLine = 0;
  947.       this.currXpos = 0;
  948.       this.currYpos = 0;
  949.       this.cursorXpos = 0;
  950.       this.cursorYpos = 0;
  951.       this.southOffset = 0;
  952.       this.lastXpos = 0;
  953.       this.lastYpos = 0;
  954.       this.beyondRightBorder = false;
  955.    }
  956.  
  957.    public void setForeground(Color var1) {
  958.       this.text.setForeground(var1);
  959.       this.nothingChanged = false;
  960.       ((Component)this).repaint();
  961.    }
  962.  
  963.    public Color getForeground() {
  964.       return this.text.getForeground();
  965.    }
  966.  
  967.    public synchronized boolean handleEvent(Event var1) {
  968.       int var2 = this.lastYpos;
  969.       int var3 = this.lastXpos;
  970.       if (this.scrollEast != null && var1.target.equals(this.scrollEast)) {
  971.          ((Component)this).requestFocus();
  972.          this.nothingChanged = false;
  973.          switch (var1.id) {
  974.             case 601:
  975.                this.dropEvent = true;
  976.                this.lastYpos -= 20;
  977.                if (var2 != this.lastYpos) {
  978.                   ((Component)this).repaint();
  979.                }
  980.  
  981.                return true;
  982.             case 602:
  983.                this.dropEvent = true;
  984.                this.lastYpos += 20;
  985.                if (this.lastYpos > this.currYpos - this.Bounds.height + 14) {
  986.                   this.lastYpos = this.currYpos - this.Bounds.height + 10 + 14;
  987.                }
  988.  
  989.                if (var2 != this.lastYpos) {
  990.                   ((Component)this).repaint();
  991.                }
  992.  
  993.                return true;
  994.             case 603:
  995.                this.dropEvent = true;
  996.                this.lastYpos = this.lastYpos - this.Bounds.height + 20;
  997.                if (this.lastYpos < 0) {
  998.                   this.lastYpos = 0;
  999.                }
  1000.  
  1001.                if (var2 != this.lastYpos) {
  1002.                   ((Component)this).repaint();
  1003.                }
  1004.  
  1005.                return true;
  1006.             case 604:
  1007.                this.dropEvent = true;
  1008.                this.lastYpos = this.lastYpos + this.Bounds.height - 20;
  1009.                if (this.lastYpos > this.currYpos - this.Bounds.height + 14) {
  1010.                   this.lastYpos = this.currYpos - this.Bounds.height + 10 + 14;
  1011.                }
  1012.  
  1013.                if (var2 != this.lastYpos) {
  1014.                   ((Component)this).repaint();
  1015.                }
  1016.  
  1017.                return true;
  1018.             case 605:
  1019.                if (this.dropEvent) {
  1020.                   this.dropEvent = false;
  1021.                   return true;
  1022.                }
  1023.  
  1024.                this.lastYpos = this.scrollEast.getValue();
  1025.                if (this.lastYpos > this.currYpos - this.Bounds.height + 14) {
  1026.                   this.lastYpos = this.currYpos - this.Bounds.height + 10 + 14;
  1027.                }
  1028.  
  1029.                if (var2 != this.lastYpos) {
  1030.                   ((Component)this).repaint();
  1031.                }
  1032.  
  1033.                return true;
  1034.          }
  1035.       }
  1036.  
  1037.       if (this.scrollSouth != null && var1.target.equals(this.scrollSouth)) {
  1038.          ((Component)this).requestFocus();
  1039.          this.nothingChanged = false;
  1040.          switch (var1.id) {
  1041.             case 601:
  1042.                this.dropEvent = true;
  1043.                this.lastXpos -= 20;
  1044.                if (var3 != this.lastXpos) {
  1045.                   ((Component)this).repaint();
  1046.                }
  1047.  
  1048.                return true;
  1049.             case 602:
  1050.                this.dropEvent = true;
  1051.                this.lastXpos += 20;
  1052.                if (this.lastXpos > this.maxLineWidth - this.Bounds.width + this.southOffset) {
  1053.                   this.lastXpos = this.maxLineWidth - this.Bounds.width + 10 + this.southOffset;
  1054.                }
  1055.  
  1056.                if (var3 != this.lastXpos) {
  1057.                   ((Component)this).repaint();
  1058.                }
  1059.  
  1060.                return true;
  1061.             case 603:
  1062.                this.dropEvent = true;
  1063.                this.lastXpos = this.lastXpos - this.Bounds.width + 20;
  1064.                if (this.lastXpos < 0) {
  1065.                   this.lastXpos = 0;
  1066.                }
  1067.  
  1068.                if (var3 != this.lastXpos) {
  1069.                   ((Component)this).repaint();
  1070.                }
  1071.  
  1072.                return true;
  1073.             case 604:
  1074.                this.dropEvent = true;
  1075.                this.lastXpos = this.lastXpos + this.Bounds.width - 20;
  1076.                if (this.lastXpos > this.maxLineWidth - this.Bounds.width + this.southOffset) {
  1077.                   this.lastXpos = this.maxLineWidth - this.Bounds.width + 10 + this.southOffset;
  1078.                }
  1079.  
  1080.                if (var3 != this.lastXpos) {
  1081.                   ((Component)this).repaint();
  1082.                }
  1083.  
  1084.                return true;
  1085.             case 605:
  1086.                if (this.dropEvent) {
  1087.                   this.dropEvent = false;
  1088.                   return true;
  1089.                }
  1090.  
  1091.                this.lastXpos = this.scrollSouth.getValue();
  1092.                if (this.lastXpos > this.maxLineWidth - this.Bounds.width + this.southOffset) {
  1093.                   this.lastXpos = this.maxLineWidth - this.Bounds.width + 10 + this.southOffset;
  1094.                }
  1095.  
  1096.                if (var3 != this.lastXpos) {
  1097.                   ((Component)this).repaint();
  1098.                }
  1099.  
  1100.                return true;
  1101.          }
  1102.       }
  1103.  
  1104.       this.dropEvent = false;
  1105.       switch (var1.id) {
  1106.          case 202:
  1107.          case 205:
  1108.             ((Component)this).repaint();
  1109.             return false;
  1110.          case 401:
  1111.             if (this.text.isEditable()) {
  1112.                this.nothingChanged = false;
  1113.                this.keyDown(var1);
  1114.             }
  1115.  
  1116.             return false;
  1117.          case 403:
  1118.             this.nothingChanged = false;
  1119.             switch (var1.key) {
  1120.                case 1002:
  1121.                   this.lastYpos = this.lastYpos - this.Bounds.height + 10;
  1122.                   if (this.lastYpos < 0) {
  1123.                      this.lastYpos = 0;
  1124.                   }
  1125.  
  1126.                   this.nothingChanged = false;
  1127.                   if (var2 != this.lastYpos) {
  1128.                      ((Component)this).repaint();
  1129.                   }
  1130.  
  1131.                   return true;
  1132.                case 1003:
  1133.                   this.lastYpos = this.lastYpos + this.Bounds.height - 10;
  1134.                   if (this.lastYpos > this.currYpos - this.Bounds.height) {
  1135.                      this.lastYpos = this.currYpos - this.Bounds.height + 10;
  1136.                   }
  1137.  
  1138.                   this.nothingChanged = false;
  1139.                   if (var2 != this.lastYpos) {
  1140.                      ((Component)this).repaint();
  1141.                   }
  1142.  
  1143.                   return true;
  1144.                case 1004:
  1145.                   int var16 = this.cursorPos - this.lineIndex[this.thisLine];
  1146.                   this.thisLine += -1;
  1147.                   if (this.thisLine < 0) {
  1148.                      this.thisLine = 0;
  1149.                      this.cursorPos = 0;
  1150.                   } else {
  1151.                      this.cursorPos = this.lineIndex[this.thisLine];
  1152.                      if (var16 + this.cursorPos >= this.lineIndex[this.thisLine + 1]) {
  1153.                         this.cursorPos = this.lineIndex[this.thisLine + 1] - 1;
  1154.                      } else {
  1155.                         this.cursorPos += var16;
  1156.                      }
  1157.                   }
  1158.  
  1159.                   if (this.cursorYpos - this.cursorFontHeight < 10) {
  1160.                      this.lastYpos -= this.cursorFontHeight;
  1161.                   }
  1162.  
  1163.                   this.adjustCursor(var1);
  1164.                   return true;
  1165.                case 1005:
  1166.                   int var15 = this.cursorPos - this.lineIndex[this.thisLine];
  1167.                   ++this.thisLine;
  1168.                   if (this.lineIndex[this.thisLine + 1] == 0) {
  1169.                      this.thisLine += -1;
  1170.                      this.cursorPos = this.lineIndex[this.thisLine + 1] - 1;
  1171.                   } else {
  1172.                      this.cursorPos = this.lineIndex[this.thisLine];
  1173.                      if (var15 + this.cursorPos > this.lineIndex[this.thisLine + 1]) {
  1174.                         this.cursorPos = this.lineIndex[this.thisLine + 1];
  1175.                      } else {
  1176.                         this.cursorPos += var15;
  1177.                      }
  1178.                   }
  1179.  
  1180.                   if (this.cursorYpos + this.cursorFontHeight > this.Bounds.height - 10) {
  1181.                      this.lastYpos += this.cursorFontHeight;
  1182.                   }
  1183.  
  1184.                   this.adjustCursor(var1);
  1185.                   return true;
  1186.                case 1006:
  1187.                   this.cursorPos += -1;
  1188.                   this.showCursor();
  1189.                   this.adjustCursor(var1);
  1190.                   return true;
  1191.                case 1007:
  1192.                   ++this.cursorPos;
  1193.                   this.showCursor();
  1194.                   this.adjustCursor(var1);
  1195.                   return true;
  1196.                default:
  1197.                   return true;
  1198.             }
  1199.          case 501:
  1200.             ((Component)this).requestFocus();
  1201.             int var14 = 0;
  1202.             int var17 = 0;
  1203.             this.thisLine = 0;
  1204.             int var18 = 0;
  1205.  
  1206.             String var21;
  1207.             for(var21 = this.text.getText(); (this.lineMousePos[var18] != 0 || this.lineMousePos[var18 + 1] != 0) && this.lineMousePos[var18] < var1.y - 4; ++var18) {
  1208.                if (var17 < this.lineIndex[this.thisLine + 1]) {
  1209.                   var17 = this.lineIndex[this.thisLine + 1];
  1210.                   ++this.thisLine;
  1211.                }
  1212.             }
  1213.  
  1214.             if (this.lineIndex[this.thisLine] > var21.length()) {
  1215.                this.cursorPos = var21.length();
  1216.             } else {
  1217.                int var8 = this.lineIndex[this.thisLine];
  1218.                int var26 = this.lineIndex[this.thisLine + 1] - 1;
  1219.                if (var26 < 0) {
  1220.                   var26 = var21.length();
  1221.                }
  1222.  
  1223.                if (var8 >= 0 && var26 >= 0) {
  1224.                   var21 = this.text.getText();
  1225.                   var21 = var21.substring(var8, var26);
  1226.                } else {
  1227.                   var21 = "";
  1228.                }
  1229.  
  1230.                int var27;
  1231.                for(var27 = 0; var27 < this.startPos.length && this.startPos[var27] < var8 + this.lastpos; ++var27) {
  1232.                }
  1233.  
  1234.                --var27;
  1235.                if (var27 < 0) {
  1236.                   var27 = 0;
  1237.                }
  1238.  
  1239.                if (this.font == null) {
  1240.                   this.field_0.setFont(((Component)this).getFont());
  1241.                } else {
  1242.                   this.field_0.setFont(this.font[var27]);
  1243.                }
  1244.  
  1245.                int var29 = 0;
  1246.  
  1247.                while(var21.length() > this.lastpos + var14 && var29 < var1.x - this.indent - this.indentWidth + this.lastXpos) {
  1248.                   ++var14;
  1249.                   if (this.lastpos + var14 > 0) {
  1250.                      if (var21.substring(this.lastpos + var14 - 1, this.lastpos + var14).equals("\t")) {
  1251.                         var29 = (var29 / this.tabWidth + 1) * this.tabWidth;
  1252.                      } else {
  1253.                         var29 += this.user.u.StringWidth(this.field_0, var21.substring(this.lastpos + var14 - 1, this.lastpos + var14));
  1254.                      }
  1255.                   }
  1256.  
  1257.                   if (var27 < this.startPos.length - 1 && var8 + this.lastpos + var14 == this.startPos[var27 + 1]) {
  1258.                      ++var27;
  1259.                      if (this.font == null) {
  1260.                         this.field_0.setFont(((Component)this).getFont());
  1261.                      } else {
  1262.                         this.field_0.setFont(this.font[var27]);
  1263.                      }
  1264.                   }
  1265.                }
  1266.  
  1267.                this.cursorPos = var17 + this.lastpos + var14;
  1268.             }
  1269.  
  1270.             this.prevCursorPos = this.cursorPos;
  1271.             int var24 = this.lastYpos;
  1272.             this.showCursor();
  1273.             this.lastYpos = var24;
  1274.             this.selectedFrom = this.cursorPos;
  1275.             this.selectedTo = this.cursorPos;
  1276.             this.initcursorPos = this.cursorPos;
  1277.             this.nothingChanged = false;
  1278.             ((Component)this).repaint();
  1279.             return true;
  1280.          case 505:
  1281.             if (this.user.jdpMainWindow != null) {
  1282.                if (this.user.jdpMainWindow.getCursorType() == 3) {
  1283.                   return false;
  1284.                }
  1285.  
  1286.                if (var1.target.equals(this)) {
  1287.                   this.user.jdpMainWindow.setCursor(0);
  1288.                   return true;
  1289.                }
  1290.             }
  1291.  
  1292.             return true;
  1293.          case 506:
  1294.             this.nothingChanged = false;
  1295.             this.lastevty = var1.y;
  1296.             this.lastevtx = var1.x;
  1297.             int var4 = 0;
  1298.             String var7 = this.text.getText();
  1299.             int var5 = 0;
  1300.             this.thisLine = 0;
  1301.             int var6 = 0;
  1302.  
  1303.             for(boolean var9 = false; (this.lineMousePos[var6] != 0 || this.lineMousePos[var6 + 1] != 0) && this.lineMousePos[var6] < var1.y - 4; ++var6) {
  1304.                if (var5 < this.lineIndex[this.thisLine + 1]) {
  1305.                   var5 = this.lineIndex[this.thisLine + 1];
  1306.                   ++this.thisLine;
  1307.                }
  1308.             }
  1309.  
  1310.             int var25;
  1311.             if (this.lineIndex[this.thisLine] > var7.length()) {
  1312.                var25 = var7.length();
  1313.             } else {
  1314.                int var10 = this.lineIndex[this.thisLine];
  1315.                int var11 = this.lineIndex[this.thisLine + 1] - 1;
  1316.                if (var11 < 0) {
  1317.                   var11 = var7.length();
  1318.                }
  1319.  
  1320.                if (var10 >= 0 && var11 >= 0) {
  1321.                   var7 = this.text.getText();
  1322.                   var7 = var7.substring(var10, var11);
  1323.                } else {
  1324.                   var7 = "";
  1325.                }
  1326.  
  1327.                int var12;
  1328.                for(var12 = 0; var12 < this.startPos.length && this.startPos[var12] < var10 + this.lastpos; ++var12) {
  1329.                }
  1330.  
  1331.                --var12;
  1332.                if (var12 < 0) {
  1333.                   var12 = 0;
  1334.                }
  1335.  
  1336.                if (this.font == null) {
  1337.                   this.field_0.setFont(((Component)this).getFont());
  1338.                } else {
  1339.                   this.field_0.setFont(this.font[var12]);
  1340.                }
  1341.  
  1342.                int var13 = 0;
  1343.  
  1344.                while(var7.length() > this.lastpos + var4 && var13 < var1.x - this.indent - this.indentWidth + this.lastXpos) {
  1345.                   ++var4;
  1346.                   if (this.lastpos + var4 > 0) {
  1347.                      if (var7.substring(this.lastpos + var4 - 1, this.lastpos + var4).equals("\t")) {
  1348.                         var13 = (var13 / this.tabWidth + 1) * this.tabWidth;
  1349.                      } else {
  1350.                         var13 += this.user.u.StringWidth(this.field_0, var7.substring(this.lastpos + var4 - 1, this.lastpos + var4));
  1351.                      }
  1352.                   }
  1353.  
  1354.                   if (var12 < this.startPos.length - 1 && var10 + this.lastpos + var4 == this.startPos[var12 + 1]) {
  1355.                      ++var12;
  1356.                      if (this.font == null) {
  1357.                         this.field_0.setFont(((Component)this).getFont());
  1358.                      } else {
  1359.                         this.field_0.setFont(this.font[var12]);
  1360.                      }
  1361.                   }
  1362.                }
  1363.  
  1364.                var25 = var5 + this.lastpos + var4;
  1365.             }
  1366.  
  1367.             if (var25 < 0 && this.cursorPos == 0) {
  1368.                if (var1.x < 0 || var1.x > ((Component)this).bounds().width || var1.y < 0 || var1.y > ((Component)this).bounds().height) {
  1369.                   this.showCursor();
  1370.                }
  1371.  
  1372.                return true;
  1373.             } else if (var25 < this.cursorPos) {
  1374.                this.cursorPos = var25;
  1375.                if (this.cursorPos >= this.selectedFrom) {
  1376.                   this.selectedTo = this.cursorPos;
  1377.                } else {
  1378.                   this.selectedFrom = this.cursorPos;
  1379.                   this.selectedTo = this.initcursorPos;
  1380.                }
  1381.  
  1382.                if (var1.x < 0 || var1.x > ((Component)this).bounds().width || var1.y < 0 || var1.y > ((Component)this).bounds().height) {
  1383.                   this.showCursor();
  1384.                }
  1385.  
  1386.                ((Component)this).repaint();
  1387.                return true;
  1388.             } else {
  1389.                if (var25 > this.cursorPos) {
  1390.                   this.cursorPos = var25;
  1391.                   if (this.cursorPos <= this.selectedTo) {
  1392.                      this.selectedFrom = this.cursorPos;
  1393.                   } else {
  1394.                      this.selectedTo = this.cursorPos;
  1395.                      this.selectedFrom = this.initcursorPos;
  1396.                   }
  1397.  
  1398.                   if (var1.x < 0 || var1.x > ((Component)this).bounds().width || var1.y < 0 || var1.y > ((Component)this).bounds().height) {
  1399.                      this.showCursor();
  1400.                   }
  1401.  
  1402.                   ((Component)this).repaint();
  1403.                   return true;
  1404.                }
  1405.  
  1406.                return false;
  1407.             }
  1408.          default:
  1409.             if (this.user.jdpMainWindow == null) {
  1410.                return false;
  1411.             } else if (this.user.jdpMainWindow.getCursorType() == 3) {
  1412.                return false;
  1413.             } else if (!var1.target.equals(this)) {
  1414.                this.user.jdpMainWindow.setCursor(0);
  1415.                return true;
  1416.             } else {
  1417.                if (this.scrollEast != null && this.scrollEast.isVisible() && var1.x > ((Component)this).bounds().width - 16) {
  1418.                   this.user.jdpMainWindow.setCursor(0);
  1419.                } else if (this.scrollSouth != null && this.scrollSouth.isVisible() && var1.y > ((Component)this).bounds().height - 16) {
  1420.                   this.user.jdpMainWindow.setCursor(0);
  1421.                } else {
  1422.                   this.user.jdpMainWindow.setCursor(2);
  1423.                }
  1424.  
  1425.                return true;
  1426.             }
  1427.       }
  1428.    }
  1429.  
  1430.    public void replaceText(String var1, int var2, int var3) {
  1431.       String var4 = this.text.getText();
  1432.       var4 = var4.substring(0, var2) + var1 + var4.substring(var3);
  1433.       this.text.setText(var4);
  1434.       this.formatText();
  1435.       this.select(var2, var2);
  1436.    }
  1437.  
  1438.    public synchronized void formatText() {
  1439.    }
  1440. }
  1441.