Skip to content

Commit

Permalink
Implement overline style.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Feb 6, 2022
1 parent 40d76c3 commit 22db60d
Show file tree
Hide file tree
Showing 18 changed files with 59 additions and 22 deletions.
4 changes: 2 additions & 2 deletions locale/de/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2153,8 +2153,8 @@ BEGIN
IDS_CUSTOMIZE_SCHEMES_HELP "Filename extensions must be separated by semicolon (;)\r\n\
\r\n\
Style format:\r\n\
\tfont:Name; size:[+|-]nn.mm; weight:nnn; bold; italic; underline; strike;\r\n\
\tcharset:dd; locale:Name;\r\n\
\tfont:Name; size:[+|-]nn.mm; weight:nnn; bold; italic;\r\n\
\tunderline; strike; overline; charset:dd; locale:Name;\r\n\
\tfore:#RRGGBB; back:#RRGGBB; alpha:aa; outline:aa; eolfilled;\r\n\
\r\n\
Style properties can be copied using copy and paste or drag and drop.\r\n\
Expand Down
4 changes: 2 additions & 2 deletions locale/it/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2153,8 +2153,8 @@ BEGIN
IDS_CUSTOMIZE_SCHEMES_HELP "Filename extensions must be separated by semicolon (;)\r\n\
\r\n\
Style format:\r\n\
\tfont:Name; size:[+|-]nn.mm; weight:nnn; bold; italic; underline; strike;\r\n\
\tcharset:dd; locale:Name;\r\n\
\tfont:Name; size:[+|-]nn.mm; weight:nnn; bold; italic;\r\n\
\tunderline; strike; overline; charset:dd; locale:Name;\r\n\
\tfore:#RRGGBB; back:#RRGGBB; alpha:aa; outline:aa; eolfilled;\r\n\
\r\n\
Style properties can be copied using copy and paste or drag and drop.\r\n\
Expand Down
4 changes: 2 additions & 2 deletions locale/ja/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2153,8 +2153,8 @@ BEGIN
IDS_CUSTOMIZE_SCHEMES_HELP "拡張子の区切りはセミコロン(;)です。\r\n\
\r\n\
設定書式: 各指定は省略可能\r\n\
\tfont:Name; size:[+|-]nn.mm; weight:nnn; bold; italic; underline; strike;\r\n\
\tcharset:dd; locale:Name;\r\n\
\tfont:Name; size:[+|-]nn.mm; weight:nnn; bold; italic;\r\n\
\tunderline; strike; overline; charset:dd; locale:Name;\r\n\
\tfore:#RRGGBB; back:#RRGGBB; alpha:aa; outline:aa; eolfilled;\r\n\
\r\n\
コピーペーストやドラッグドロップでも指定を変更できます。\r\n\
Expand Down
4 changes: 2 additions & 2 deletions locale/ko/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2153,8 +2153,8 @@ BEGIN
IDS_CUSTOMIZE_SCHEMES_HELP "확장자는 세미콜론(;)으로 구분되어야 합니다.\r\n\
\r\n\
스타일 형식:\r\n\
\tfont:Name; size:[+|-]nn.mm; weight:nnn; bold; italic; underline; strike;\r\n\
\tcharset:dd; locale:Name;\r\n\
\tfont:Name; size:[+|-]nn.mm; weight:nnn; bold; italic;\r\n\
\tunderline; strike; overline; charset:dd; locale:Name;\r\n\
\tfore:#RRGGBB; back:#RRGGBB; alpha:aa; outline:aa; eolfilled;\r\n\
\r\n\
스타일 속성은 복사/붙여넣기, 또는 끌어서 놓기로 복사할 수 있습니다.\r\n\
Expand Down
4 changes: 2 additions & 2 deletions locale/zh-Hans/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2153,8 +2153,8 @@ BEGIN
IDS_CUSTOMIZE_SCHEMES_HELP "文件扩展名必须由分号(;)分隔\r\n\
\r\n\
样式格式:\r\n\
\tfont:Name; size:[+|-]nn.mm; weight:nnn; bold; italic; underline; strike;\r\n\
\tcharset:dd; locale:Name;\r\n\
\tfont:Name; size:[+|-]nn.mm; weight:nnn; bold; italic;\r\n\
\tunderline; strike; overline; charset:dd; locale:Name;\r\n\
\tfore:#RRGGBB; back:#RRGGBB; alpha:aa; outline:aa; eolfilled;\r\n\
\r\n\
样式属性可以用复制并粘贴或者拖放来复制。\r\n\
Expand Down
4 changes: 2 additions & 2 deletions locale/zh-Hant/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2153,8 +2153,8 @@ BEGIN
IDS_CUSTOMIZE_SCHEMES_HELP "檔案副檔名稱必須由分號 (;) 分隔\r\n\
\r\n\
樣式格式:\r\n\
\tfont:Name; size:[+|-]nn.mm; weight:nnn; bold; italic; underline; strike;\r\n\
\tcharset:dd; locale:Name;\r\n\
\tfont:Name; size:[+|-]nn.mm; weight:nnn; bold; italic;\r\n\
\tunderline; strike; overline; charset:dd; locale:Name;\r\n\
\tfore:#RRGGBB; back:#RRGGBB; alpha:aa; outline:aa; eolfilled;\r\n\
\r\n\
樣式屬性可以用複製並貼上或拖放來複製。\r\n\
Expand Down
4 changes: 4 additions & 0 deletions scintilla/call/ScintillaCall.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,10 @@ void ScintillaCall::StyleSetStrike(int style, bool strike) {
Call(Message::StyleSetStrike, style, strike);
}

void ScintillaCall::StyleSetOverline(int style, bool overline) {
Call(Message::StyleSetOverline, style, overline);
}

Colour ScintillaCall::StyleGetFore(int style) {
return static_cast<Colour>(Call(Message::StyleGetFore, style));
}
Expand Down
3 changes: 2 additions & 1 deletion scintilla/include/Scintilla.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ typedef sptr_t (*SciFnDirectStatus)(sptr_t ptr, unsigned int iMessage, uptr_t wP
#define SCI_STYLESETEOLFILLED 2057
#define SCI_STYLERESETDEFAULT 2058
#define SCI_STYLESETUNDERLINE 2059
#define SCI_STYLESETSTRIKE 2474
#define SCI_STYLESETSTRIKE 2041
#define SCI_STYLESETOVERLINE 2042
#define SC_CASE_MIXED 0
#define SC_CASE_UPPER 1
#define SC_CASE_LOWER 2
Expand Down
5 changes: 4 additions & 1 deletion scintilla/include/Scintilla.iface
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,10 @@ fun void StyleResetDefault=2058(,)
set void StyleSetUnderline=2059(int style, bool underline)

# Set a style to be strike or not.
set void StyleSetStrike=2474(int style, bool strike)
set void StyleSetStrike=2041(int style, bool strike)

# Set a style to be overline or not.
set void StyleSetOverline=2042(int style, bool overline)

enu CaseVisible=SC_CASE_
val SC_CASE_MIXED=0
Expand Down
1 change: 1 addition & 0 deletions scintilla/include/ScintillaCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class ScintillaCall {
void StyleResetDefault();
void StyleSetUnderline(int style, bool underline);
void StyleSetStrike(int style, bool strike);
void StyleSetOverline(int style, bool overline);
Colour StyleGetFore(int style);
Colour StyleGetBack(int style);
bool StyleGetBold(int style);
Expand Down
3 changes: 2 additions & 1 deletion scintilla/include/ScintillaMessages.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ enum class Message {
StyleSetEOLFilled = 2057,
StyleResetDefault = 2058,
StyleSetUnderline = 2059,
StyleSetStrike = 2474,
StyleSetStrike = 2041,
StyleSetOverline = 2042,
StyleGetFore = 2481,
StyleGetBack = 2482,
StyleGetBold = 2483,
Expand Down
8 changes: 6 additions & 2 deletions scintilla/src/EditView.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2534,12 +2534,16 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
rcUL.top = rcUL.top + vsDraw.maxAscent + 1;
rcUL.bottom = rcUL.top + 1;
surface->FillRectangleAligned(rcUL, Fill(textFore));
// Added strike style, 2011-12-20
} else if (vsDraw.styles[styleMain].strike) {
} else if (vsDraw.styles[styleMain].strike) { // 2011-12-20
PRectangle rcUL = rcSegment;
rcUL.top = rcUL.top + std::ceil((rcUL.bottom - rcUL.top) / 2);
rcUL.bottom = rcUL.top + 1;
surface->FillRectangleAligned(rcUL, Fill(textFore));
} else if (vsDraw.styles[styleMain].overline) {// 2022-02-06
PRectangle rcUL = rcSegment;
rcUL.top = rcUL.top + 1;
rcUL.bottom = rcUL.top + 1;
surface->FillRectangleAligned(rcUL, Fill(textFore));
}
} else if (rcSegment.left > rcLine.right) {
break;
Expand Down
7 changes: 5 additions & 2 deletions scintilla/src/Editor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -5836,10 +5836,12 @@ void Editor::StyleSetMessage(Message iMessage, uptr_t wParam, sptr_t lParam) {
case Message::StyleSetUnderline:
vs.styles[wParam].underline = lParam != 0;
break;
// Added strike style, 2011-12-20
case Message::StyleSetStrike:
case Message::StyleSetStrike: // 2011-12-20
vs.styles[wParam].strike = lParam != 0;
break;
case Message::StyleSetOverline: // 2022-02-06
vs.styles[wParam].overline = lParam != 0;
break;
case Message::StyleSetCase:
vs.styles[wParam].caseForce = static_cast<Style::CaseForce>(lParam);
break;
Expand Down Expand Up @@ -7286,6 +7288,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
case Message::StyleSetFont:
case Message::StyleSetUnderline:
case Message::StyleSetStrike:
case Message::StyleSetOverline:
case Message::StyleSetCase:
case Message::StyleSetCharacterSet:
case Message::StyleSetVisible:
Expand Down
1 change: 1 addition & 0 deletions scintilla/src/Style.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ struct StylePod {
bool eolFilled = false;
bool underline = false;
bool strike = false;
bool overline = false;
enum class CaseForce : uint8_t {
mixed, upper, lower, camel
};
Expand Down
4 changes: 2 additions & 2 deletions src/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2153,8 +2153,8 @@ BEGIN
IDS_CUSTOMIZE_SCHEMES_HELP "Filename extensions must be separated by semicolon (;)\r\n\
\r\n\
Style format:\r\n\
\tfont:Name; size:[+|-]nn.mm; weight:nnn; bold; italic; underline; strike;\r\n\
\tcharset:dd; locale:Name;\r\n\
\tfont:Name; size:[+|-]nn.mm; weight:nnn; bold; italic;\r\n\
\tunderline; strike; overline; charset:dd; locale:Name;\r\n\
\tfore:#RRGGBB; back:#RRGGBB; alpha:aa; outline:aa; eolfilled;\r\n\
\r\n\
Style properties can be copied using copy and paste or drag and drop.\r\n\
Expand Down
4 changes: 4 additions & 0 deletions src/SciCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,10 @@ NP2_inline void SciCall_StyleSetStrike(int style, BOOL strike) {
SciCall(SCI_STYLESETSTRIKE, style, strike);
}

NP2_inline void SciCall_StyleSetOverline(int style, BOOL overline) {
SciCall(SCI_STYLESETOVERLINE, style, overline);
}

NP2_inline void SciCall_StyleSetFore(int style, COLORREF fore) {
SciCall(SCI_STYLESETFORE, style, fore);
}
Expand Down
15 changes: 15 additions & 0 deletions src/Styles.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ struct DetailStyle {
BOOL italic;
BOOL underline;
BOOL strike;
BOOL overline;
BOOL eolFilled;
int charset;
WCHAR fontWide[LF_FACESIZE];
Expand Down Expand Up @@ -1500,6 +1501,7 @@ static BOOL Style_StrGetAttributeEx(LPCWSTR lpszStyle, LPCWSTR key, int keyLen)
#define Style_StrGetItalic(lpszStyle) Style_StrGetAttribute((lpszStyle), L"italic")
#define Style_StrGetUnderline(lpszStyle) Style_StrGetAttribute((lpszStyle), L"underline")
#define Style_StrGetStrike(lpszStyle) Style_StrGetAttribute((lpszStyle), L"strike")
#define Style_StrGetOverline(lpszStyle) Style_StrGetAttribute((lpszStyle), L"overline")
#define Style_StrGetEOLFilled(lpszStyle) Style_StrGetAttribute((lpszStyle), L"eolfilled")

// set default colors to avoid showing white (COLOR_WINDOW or COLOR_3DFACE) window or margin while loading big file.
Expand Down Expand Up @@ -3587,6 +3589,7 @@ BOOL Style_StrGetLocale(LPCWSTR lpszStyle, LPWSTR lpszLocale, int cchLocale) {
#define Style_StrCopyItalic(szNewStyle, lpszStyle) Style_StrCopyAttribute((szNewStyle), (lpszStyle), L"italic")
#define Style_StrCopyUnderline(szNewStyle, lpszStyle) Style_StrCopyAttribute((szNewStyle), (lpszStyle), L"underline")
#define Style_StrCopyStrike(szNewStyle, lpszStyle) Style_StrCopyAttribute((szNewStyle), (lpszStyle), L"strike")
#define Style_StrCopyOverline(szNewStyle, lpszStyle) Style_StrCopyAttribute((szNewStyle), (lpszStyle), L"overline")
#define Style_StrCopyEOLFilled(szNewStyle, lpszStyle) Style_StrCopyAttribute((szNewStyle), (lpszStyle), L"eolfilled")

//=============================================================================
Expand Down Expand Up @@ -3721,6 +3724,7 @@ BOOL Style_SelectFont(HWND hwnd, LPWSTR lpszStyle, int cchStyle, BOOL bDefaultSt
lstrcat(szNewStyle, L"; strike");
}

Style_StrCopyOverline(szNewStyle, lpszStyle);
Style_StrCopyCase(szNewStyle, lpszStyle, tch);
Style_StrCopyFore(szNewStyle, lpszStyle, tch);
Style_StrCopyBack(szNewStyle, lpszStyle, tch);
Expand Down Expand Up @@ -3785,6 +3789,7 @@ BOOL Style_SelectColor(HWND hwnd, BOOL bFore, LPWSTR lpszStyle, int cchStyle) {
Style_StrCopyItalic(szNewStyle, lpszStyle);
Style_StrCopyUnderline(szNewStyle, lpszStyle);
Style_StrCopyStrike(szNewStyle, lpszStyle);
Style_StrCopyOverline(szNewStyle, lpszStyle);
Style_StrCopyCase(szNewStyle, lpszStyle, tch);

if (bFore) {
Expand Down Expand Up @@ -3859,6 +3864,10 @@ void Style_SetStyles(int iStyle, LPCWSTR lpszStyle) {
if (Style_StrGetStrike(lpszStyle)) {
SciCall_StyleSetStrike(iStyle, TRUE);
}
// Overline
if (Style_StrGetOverline(lpszStyle)) {
SciCall_StyleSetOverline(iStyle, TRUE);
}
// EOL Filled
if (Style_StrGetEOLFilled(lpszStyle)) {
SciCall_StyleSetEOLFilled(iStyle, TRUE);
Expand Down Expand Up @@ -3912,6 +3921,8 @@ void Style_Parse(struct DetailStyle *style, LPCWSTR lpszStyle) {
style->underline = Style_StrGetUnderline(lpszStyle);
// Strike
style->strike = Style_StrGetStrike(lpszStyle);
// Overline
style->overline = Style_StrGetOverline(lpszStyle);
// EOL Filled
style->eolFilled = Style_StrGetEOLFilled(lpszStyle);

Expand Down Expand Up @@ -3964,6 +3975,10 @@ void Style_SetParsed(const struct DetailStyle *style, int iStyle) {
if (style->strike) {
SciCall_StyleSetStrike(iStyle, TRUE);
}
// Overline
if (style->overline) {
SciCall_StyleSetOverline(iStyle, TRUE);
}
// EOL Filled
if (style->eolFilled) {
SciCall_StyleSetEOLFilled(iStyle, TRUE);
Expand Down
2 changes: 1 addition & 1 deletion wiki
Submodule wiki updated from a14f6c to 07b635

0 comments on commit 22db60d

Please sign in to comment.