Files

54 lines
1.0 KiB
C++
Raw Permalink Normal View History

2014-01-31 08:23:00 +13:00
2019-01-18 15:55:40 +01:00
#include "sourcefile.hpp"
#include "prefs.hpp"
2019-01-18 17:04:34 +01:00
#include "stdafx.hpp"
2014-01-31 08:23:00 +13:00
2019-01-18 17:04:34 +01:00
IMPLEMENT_DYNAMIC(SourceFile, CRichEditCtrl)
BEGIN_MESSAGE_MAP(SourceFile, CRichEditCtrl)
ON_WM_CREATE()
2014-01-31 08:23:00 +13:00
END_MESSAGE_MAP()
2019-01-18 17:04:34 +01:00
SourceFile::SourceFile() {}
2014-01-31 08:23:00 +13:00
2019-01-18 17:04:34 +01:00
SourceFile::~SourceFile() {}
2014-01-31 08:23:00 +13:00
2019-01-18 17:04:34 +01:00
int SourceFile::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
CRichEditCtrl::OnCreate(lpCreateStruct);
2014-01-31 08:23:00 +13:00
2019-01-18 17:04:34 +01:00
SetReadOnly(true);
SetFont(&prefs.editFont);
SetBackgroundColor(false, prefs.rgb_bkgrnd);
2014-01-31 08:23:00 +13:00
2019-01-18 17:04:34 +01:00
CHARFORMAT fmt = {sizeof(fmt)};
fmt.dwMask = CFM_COLOR;
fmt.crTextColor = prefs.rgb_default;
2014-01-31 08:23:00 +13:00
2019-01-18 17:04:34 +01:00
SetSel(0, -1);
SetDefaultCharFormat(fmt);
SetSelectionCharFormat(fmt);
SetSel(0, 0);
2014-01-31 08:23:00 +13:00
return 0;
}
2019-01-18 17:04:34 +01:00
void SourceFile::highLight(int row, int col)
{
int pos = LineIndex(row) + col;
HideSelection(true, false);
bool quote = false;
int end = pos, len = GetTextLength();
while (end < len) {
SetSel(end, end + 1);
auto txt = GetSelText();
2019-01-18 17:04:34 +01:00
if (txt[0] == '\"')
quote = !quote;
if (!quote && (txt[0] == ':' || !isprint(txt[0])))
break;
2014-01-31 08:23:00 +13:00
++end;
}
2019-01-18 17:04:34 +01:00
HideSelection(false, false);
SetSel(pos, end);
2014-01-31 08:23:00 +13:00
}