| 2911 | } |
| 2912 | |
| 2913 | void Editor::DrawLine ( Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart, |
| 2914 | PRectangle rcLine, LineLayout *ll, int subLine ) |
| 2915 | { |
| 2916 | PRectangle rcSegment = rcLine; |
| 2917 | // Using one font for all control characters so it can be controlled independently to ensure |
| 2918 | // the box goes around the characters tightly. Seems to be no way to work out what height |
| 2919 | // is taken by an individual character - internal leading gives varying results. |
| 2920 | Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; |
| 2921 | // See if something overrides the line background color: Either if caret is on the line |
| 2922 | // and background color is set for that, or if a marker is defined that forces its background |
| 2923 | // color onto the line, or if a marker is defined but has no selection margin in which to |
| 2924 | // display itself (as long as it's not an SC_MARK_EMPTY marker). These are checked in order |
| 2925 | // with the earlier taking precedence. When multiple markers cause background override, |
| 2926 | // the color for the highest numbered one is used. |
| 2927 | bool overrideBackground = false; |
| 2928 | ColourDesired background; |
| 2929 | if ( ( caret.active || vsDraw.alwaysShowCaretLineBackground ) && vsDraw.showCaretLineBackground && ( vsDraw.caretLineAlpha == SC_ALPHA_NOALPHA ) |
| 2930 | && ll->containsCaret ) { |
| 2931 | overrideBackground = true; |
| 2932 | background = vsDraw.caretLineBackground; |
| 2933 | } |
| 2934 | if ( !overrideBackground ) { |
| 2935 | int marks = pdoc->GetMark ( line ); |
| 2936 | for ( int markBit = 0; ( markBit < 32 ) && marks; markBit++ ) { |
| 2937 | if ( ( marks & 1 ) && ( vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND ) && |
| 2938 | ( vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA ) ) { |
| 2939 | background = vsDraw.markers[markBit].back; |
| 2940 | overrideBackground = true; |
| 2941 | } |
| 2942 | marks >>= 1; |
| 2943 | } |
| 2944 | } |
| 2945 | if ( !overrideBackground ) { |
| 2946 | if ( vsDraw.maskInLine ) { |
| 2947 | int marksMasked = pdoc->GetMark ( line ) & vsDraw.maskInLine; |
| 2948 | if ( marksMasked ) { |
| 2949 | for ( int markBit = 0; ( markBit < 32 ) && marksMasked; markBit++ ) { |
| 2950 | if ( ( marksMasked & 1 ) && ( vsDraw.markers[markBit].markType != SC_MARK_EMPTY ) && |
| 2951 | ( vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA ) ) { |
| 2952 | overrideBackground = true; |
| 2953 | background = vsDraw.markers[markBit].back; |
| 2954 | } |
| 2955 | marksMasked >>= 1; |
| 2956 | } |
| 2957 | } |
| 2958 | } |
| 2959 | } |
| 2960 | bool drawWhitespaceBackground = ( vsDraw.viewWhitespace != wsInvisible ) && |
| 2961 | ( !overrideBackground ) && ( vsDraw.whitespaceBackgroundSet ); |
| 2962 | bool inIndentation = subLine == 0; // Do not handle indentation except on first subline. |
| 2963 | const XYPOSITION indentWidth = pdoc->IndentSize() * vsDraw.spaceWidth; |
| 2964 | const XYPOSITION epsilon = 0.0001f; // A small nudge to avoid floating point precision issues |
| 2965 | int posLineStart = pdoc->LineStart ( line ); |
| 2966 | int startseg = ll->LineStart ( subLine ); |
| 2967 | XYACCUMULATOR subLineStart = ll->positions[startseg]; |
| 2968 | if ( subLine >= ll->lines ) { |
| 2969 | DrawAnnotation ( surface, vsDraw, line, xStart, rcLine, ll, subLine ); |
| 2970 | return; // No further drawing |
no test coverage detected