@@ -604,12 +604,6 @@ public Segment getCurrentLine() {
604604 }
605605
606606
607- // /** Old paintLine() method with kooky args order, kept around for X Mode. */
608- // @Deprecated
609- // protected void paintLine(Graphics gfx, TokenMarker tokenMarker,
610- // int line, int x) {
611- // Font defaultFont = getFont();
612- // Color defaultColor = getForeground();
613607 protected void paintLine (Graphics gfx , int line , int x ,
614608 TokenMarkerState tokenMarker ) {
615609 currentLineIndex = line ;
@@ -625,40 +619,37 @@ protected void paintLine(Graphics gfx, int line, int x,
625619 }
626620
627621
628- // protected void paintLine(Graphics gfx, int line, int x,
629- // TokenMarker tokenMarker) {
630- // paintLine(gfx, tokenMarker, line, x);
631- // }
632-
633-
634- // protected void paintPlainLine(Graphics gfx, int line, Font defaultFont,
635- // Color defaultColor, int x, int y) {
636622 protected void paintPlainLine (Graphics gfx , int line , int x , int y ) {
637- paintHighlight (gfx ,line ,y );
638- textArea .getLineText (line , currentLine );
623+ paintHighlight (gfx , line , y );
639624
640- // gfx.setFont(plainFont);
641- // gfx.setFont(defaultFont);
642- // gfx.setColor(defaultColor);
625+ // don't try to draw lines past where they exist in the document
626+ // https://github.com/processing/processing/issues/5628
627+ if (line < textArea .getLineCount ()) {
628+ textArea .getLineText (line , currentLine );
643629
644- int x0 = x - textArea .getHorizontalOffset ();
630+ int x0 = x - textArea .getHorizontalOffset ();
631+ // prevent the blinking from drawing with last color used
632+ // https://github.com/processing/processing/issues/5628
633+ gfx .setColor (defaults .fgcolor );
634+ gfx .setFont (plainFont );
645635
646- y += fm .getHeight ();
647- // doesn't respect fixed width like it should
636+ y += fm .getHeight ();
637+ // doesn't respect fixed width like it should
648638// x = Utilities.drawTabbedText(currentLine, x, y, gfx, this, 0);
649639// int w = fm.charWidth(' ');
650- for (int i = 0 ; i < currentLine .count ; i ++) {
651- gfx .drawChars (currentLine .array , currentLine .offset +i , 1 , x , y );
652- x = currentLine .array [currentLine .offset + i ] == '\t' ?
640+ for (int i = 0 ; i < currentLine .count ; i ++) {
641+ gfx .drawChars (currentLine .array , currentLine .offset +i , 1 , x , y );
642+ x = currentLine .array [currentLine .offset + i ] == '\t' ?
653643 x0 + (int )nextTabStop (x - x0 , i ) :
654644 x + fm .charWidth (currentLine .array [currentLine .offset +i ]);
655- textArea .offsetToX (line , currentLine .offset + i );
656- }
645+ // textArea.offsetToX(line, currentLine.offset + i);
646+ }
657647
658- // Draw characters via input method.
659- if (compositionTextPainter != null &&
648+ // Draw characters via input method.
649+ if (compositionTextPainter != null &&
660650 compositionTextPainter .hasComposedTextLayout ()) {
661- compositionTextPainter .draw (gfx , defaults .lineHighlightColor );
651+ compositionTextPainter .draw (gfx , defaults .lineHighlightColor );
652+ }
662653 }
663654 if (defaults .eolMarkers ) {
664655 gfx .setColor (defaults .eolMarkerColor );
@@ -667,9 +658,6 @@ protected void paintPlainLine(Graphics gfx, int line, int x, int y) {
667658 }
668659
669660
670- // protected void paintSyntaxLine(Graphics gfx, TokenMarker tokenMarker,
671- // int line, Font defaultFont,
672- // Color defaultColor, int x, int y) {
673661 protected void paintSyntaxLine (Graphics gfx , int line , int x , int y ,
674662 TokenMarkerState tokenMarker ) {
675663 textArea .getLineText (currentLineIndex , currentLine );
0 commit comments