Skip to content

Commit 35a26d1

Browse files
committed
Fixed problems with selected text and line preambles
1 parent 549e662 commit 35a26d1

File tree

4 files changed

+45
-36
lines changed

4 files changed

+45
-36
lines changed

Line.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ CLine::CLine (const long nLineNumber,
3535
hard_return = false;
3636
len = 0;
3737
last_space = -1;
38+
m_iPreambleOffset = 0;
3839
m_theTime = CTime::GetCurrentTime();
3940
QueryPerformanceCounter (&m_lineHighPerformanceTime);
4041
m_nLineNumber = nLineNumber;

OtherTypes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ class CLine : public CObject
329329
int iMemoryAllocated; // size of buffer allocated for "text"
330330

331331
long m_nLineNumber;
332+
short m_iPreambleOffset; // how far in the preamble took us
332333

333334
CLine (const long nLineNumber,
334335
const unsigned int nWrapColumn,

mushview.cpp

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,36 @@ COLORREF iBackColour = BLACK;
10711071
startcol = MIN (m_selstart_col, pLine->len);
10721072
endcol = MIN (m_selend_col, pLine->len);
10731073

1074+
// line preamble - version 4.62
1075+
1076+
CString strPreamble;
1077+
COLORREF cPreambleText,
1078+
cPreambleBack;
1079+
1080+
// get appropriate preamble text, and colours, depending on line type
1081+
if (pLine->flags & COMMENT)
1082+
{
1083+
strPreamble = pDoc->m_strOutputLinePreambleNotes;
1084+
cPreambleText = pDoc->m_OutputLinePreambleNotesTextColour;
1085+
cPreambleBack = pDoc->m_OutputLinePreambleNotesBackColour;
1086+
}
1087+
else if (pLine->flags & USER_INPUT)
1088+
{
1089+
strPreamble = pDoc->m_strOutputLinePreambleInput;
1090+
cPreambleText = pDoc->m_OutputLinePreambleInputTextColour;
1091+
cPreambleBack = pDoc->m_OutputLinePreambleInputBackColour;
1092+
}
1093+
else
1094+
{
1095+
strPreamble = pDoc->m_strOutputLinePreambleOutput;
1096+
cPreambleText = pDoc->m_OutputLinePreambleOutputTextColour;
1097+
cPreambleBack = pDoc->m_OutputLinePreambleOutputBackColour;
1098+
}
1099+
1100+
// convert codes like %H:%M:%S
1101+
if (!strPreamble.IsEmpty ())
1102+
strPreamble = pDoc->FormatTime (pLine->m_theTime, strPreamble, false);
1103+
10741104
// Draw the background and then the text
10751105

10761106
for (int iPass = 0; iPass < 2; iPass++)
@@ -1081,41 +1111,14 @@ COLORREF iBackColour = BLACK;
10811111

10821112
// line preamble - version 4.62
10831113

1084-
CString strPreamble;
1085-
COLORREF cPreambleText,
1086-
cPreambleBack;
1087-
1088-
// get appropriate preamble text, and colours, depending on line type
1089-
if (pLine->flags & COMMENT)
1090-
{
1091-
strPreamble = pDoc->m_strOutputLinePreambleNotes;
1092-
cPreambleText = pDoc->m_OutputLinePreambleNotesTextColour;
1093-
cPreambleBack = pDoc->m_OutputLinePreambleNotesBackColour;
1094-
}
1095-
else if (pLine->flags & USER_INPUT)
1096-
{
1097-
strPreamble = pDoc->m_strOutputLinePreambleInput;
1098-
cPreambleText = pDoc->m_OutputLinePreambleInputTextColour;
1099-
cPreambleBack = pDoc->m_OutputLinePreambleInputBackColour;
1100-
}
1101-
else
1102-
{
1103-
strPreamble = pDoc->m_strOutputLinePreambleOutput;
1104-
cPreambleText = pDoc->m_OutputLinePreambleOutputTextColour;
1105-
cPreambleBack = pDoc->m_OutputLinePreambleOutputBackColour;
1106-
}
1107-
11081114
// if not empty, do the work of drawing it
11091115
if (!strPreamble.IsEmpty ())
11101116
{
1111-
// convert codes like %H:%M:%S
1112-
strPreamble = pDoc->FormatTime (pLine->m_theTime, strPreamble, false);
11131117

11141118
// get plain font
11151119
pDC->SelectObject(pDoc->m_font [0]);
11161120

11171121
// find how big, so we can fill the background
1118-
11191122
RECT r;
11201123
CSize textsize = pDC->GetTextExtent (strPreamble, strPreamble.GetLength ());
11211124

@@ -1137,6 +1140,7 @@ COLORREF iBackColour = BLACK;
11371140
pDC->FillSolidRect (&r, pDoc->TranslateColour (cPreambleBack));
11381141
else
11391142
{
1143+
pDC->SetBkMode (TRANSPARENT); // trouble brewing if this isn't here!
11401144
pDC->SetTextColor (pDoc->TranslateColour (cPreambleText));
11411145
pDC->ExtTextOut (r.left,
11421146
r.top,
@@ -1146,6 +1150,7 @@ COLORREF iBackColour = BLACK;
11461150
strPreamble.GetLength (),
11471151
NULL);
11481152
}
1153+
pLine->m_iPreambleOffset = textsize.cx; // for selection calculations
11491154
pixel += textsize.cx; // start rest of line further over
11501155

11511156
}
@@ -1726,6 +1731,7 @@ long pixel;
17261731
point.y -= pDoc->m_TextRectangle.top;
17271732
point.x -= pDoc->m_TextRectangle.left;
17281733

1734+
17291735
line = (point.y + pDoc->m_iPixelOffset + m_scroll_position.y) / pDoc->m_FontHeight;
17301736

17311737
// include partial last line if necessary
@@ -1744,14 +1750,16 @@ long pixel;
17441750

17451751
CLine * pLine = pDoc->m_LineList.GetAt (pDoc->GetLinePosition (line));
17461752

1753+
// point.x -= pLine->m_iPreambleOffset;
1754+
17471755
// calculate which column we must be at
17481756

1749-
for (col = pixel = 0;
1757+
for (col = 0, pixel = pLine->m_iPreambleOffset;
17501758
pixel < point.x && col <= pLine->len;
17511759
col++)
17521760
{
17531761
lastx = pixel;
1754-
pixel = calculate_width (line, col, pDoc, dc) + pDoc->m_iPixelOffset;
1762+
pixel = calculate_width (line, col, pDoc, dc) + pDoc->m_iPixelOffset + pLine->m_iPreambleOffset;
17551763
}
17561764

17571765
col--; // columns are zero-relative
@@ -2357,7 +2365,7 @@ int line,
23572365

23582366
// first work out the line/column the mouse is over
23592367

2360-
calculate_line_and_column (point, dc, line, col, false);
2368+
calculate_line_and_column (point, dc, line, col, true);
23612369

23622370
// tooltips stuff
23632371

@@ -2374,10 +2382,6 @@ int line,
23742382
m_nLastToolTipColumn = col;
23752383
}
23762384

2377-
// first work out the line/column the mouse is over
2378-
2379-
calculate_line_and_column (point, dc, line, col, true);
2380-
23812385
// end of tooltips stuff
23822386

23832387
// only if the user is currently drawing a new stroke by dragging
@@ -2722,7 +2726,10 @@ ASSERT_VALID(pDoc);
27222726
POSITION foundpos;
27232727

27242728
// don't show finger pointer *past* end of last word
2725-
long pixel = calculate_width (line, pLine->len, pDoc, dc) + pDoc->m_iPixelOffset + pDoc->m_TextRectangle.left;
2729+
long pixel = calculate_width (line, pLine->len, pDoc, dc) +
2730+
pDoc->m_iPixelOffset +
2731+
pDoc->m_TextRectangle.left +
2732+
pLine->m_iPreambleOffset;
27262733

27272734
if (pDoc->FindStyle (pLine, col, iCol, pStyle, foundpos))
27282735
{

resource.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,7 @@
15621562
#ifdef APSTUDIO_INVOKED
15631563
#ifndef APSTUDIO_READONLY_SYMBOLS
15641564
#define _APS_3D_CONTROLS 1
1565-
#define _APS_NEXT_RESOURCE_VALUE 361
1565+
#define _APS_NEXT_RESOURCE_VALUE 362
15661566
#define _APS_NEXT_COMMAND_VALUE 33054
15671567
#define _APS_NEXT_CONTROL_VALUE 2897
15681568
#define _APS_NEXT_SYMED_VALUE 312

0 commit comments

Comments
 (0)