Skip to content

Commit

Permalink
encoding / code-page fixes and other changes provided for Notepad3
Browse files Browse the repository at this point in the history
  • Loading branch information
RaiKoHoff committed Aug 6, 2017
1 parent 2de6a1f commit c860bc7
Show file tree
Hide file tree
Showing 12 changed files with 5,543 additions and 6,189 deletions.
2 changes: 1 addition & 1 deletion build_no.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6
17
2 changes: 1 addition & 1 deletion res/Notepad2Crypt.exe.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<assemblyIdentity
name="Notepad2Crypt"
processorArchitecture="*"
version="5.2.25.985"
version="5.0.0.1"
type="win32"
/>
<description>Notepad2Crypt</description>
Expand Down
3 changes: 2 additions & 1 deletion scintilla/doc/ScintillaDoc.html
Original file line number Diff line number Diff line change
Expand Up @@ -2897,7 +2897,8 @@ <h2 id="StyleDefinition">Style definition</h2>
number used by the C and C++ lexer to display literal strings; it has the value 6). This
feature works differently on Windows and GTK+.<br />
The default character set is <code>SC_CHARSET_DEFAULT</code>.</p>
<p><code>SC_CHARSET_ANSI</code> and <code>SC_CHARSET_DEFAULT</code> specify European Windows code page 1252 unless the code page is set.</p>
<p><code>SC_CHARSET_ANSI</code> specifies European Windows code page 1252.</p>
<p><code>SC_CHARSET_DEFAULT</code> specifies the system-default code page unless the code page is set.</p>

<table class="standard" summary="Character Sets supported"><tbody>
<tr>
Expand Down
4 changes: 2 additions & 2 deletions scintilla/doc/ScintillaHistory.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
Expand Down Expand Up @@ -1028,7 +1028,7 @@ <h3>
C++11 range-based for loops used in SciTE so GCC 4.6 is now the minimum supported version.
</li>
<li>
SC_CHARSET_DEFAULT now means code page 1252 on Windows unless a code page is set.
(REVERTED in Notepad2-mod) SC_CHARSET_DEFAULT now means code page 1252 on Windows unless a code page is set.
This prevents unexpected behaviour and crashes on East Asian systems where default locales are commonly DBCS.
Projects which want to default to DBCS code pages in East Asian locales should set the code page and
character set explicitly.
Expand Down
48 changes: 24 additions & 24 deletions scintilla/win32/PlatWin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ struct FormatAndMetrics {
}
#if defined(USE_D2D)
FormatAndMetrics(IDWriteTextFormat *pTextFormat_,
int extraFontFlag_,
int characterSet_,
FLOAT yAscent_,
FLOAT yDescent_,
FLOAT yInternalLeading_) :
int extraFontFlag_,
int characterSet_,
FLOAT yAscent_,
FLOAT yDescent_,
FLOAT yInternalLeading_) :
technology(SCWIN_TECH_DIRECTWRITE),
hfont(0),
pTextFormat(pTextFormat_),
Expand Down Expand Up @@ -782,15 +782,15 @@ void SurfaceGDI::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fil

DWORD valEmpty = dwordFromBGRA(0,0,0,0);
DWORD valFill = dwordFromBGRA(
LOBYTE(fill.GetBlue() * alphaFill / 255),
LOBYTE(fill.GetGreen() * alphaFill / 255),
LOBYTE(fill.GetRed() * alphaFill / 255),
LOBYTE(alphaFill));
static_cast<byte>(fill.GetBlue() * alphaFill / 255),
static_cast<byte>(fill.GetGreen() * alphaFill / 255),
static_cast<byte>(fill.GetRed() * alphaFill / 255),
static_cast<byte>(alphaFill));
DWORD valOutline = dwordFromBGRA(
LOBYTE(outline.GetBlue() * alphaFill / 255),
LOBYTE(outline.GetGreen() * alphaFill / 255),
LOBYTE(outline.GetRed() * alphaFill / 255),
LOBYTE(alphaOutline));
static_cast<byte>(outline.GetBlue() * alphaFill / 255),
static_cast<byte>(outline.GetGreen() * alphaFill / 255),
static_cast<byte>(outline.GetRed() * alphaFill / 255),
static_cast<byte>(alphaOutline));
DWORD *pixels = static_cast<DWORD *>(image);
for (int y=0; y<height; y++) {
for (int x=0; x<width; x++) {
Expand Down Expand Up @@ -1370,8 +1370,8 @@ void SurfaceD2D::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired
void SurfaceD2D::FillRectangle(PRectangle rc, ColourDesired back) {
if (pRenderTarget) {
D2DPenColour(back);
D2D1_RECT_F rectangle1 = D2D1::RectF(RoundFloat(rc.left), rc.top, RoundFloat(rc.right), rc.bottom);
pRenderTarget->FillRectangle(&rectangle1, pBrush);
D2D1_RECT_F rectangle1 = D2D1::RectF(RoundFloat(rc.left), rc.top, RoundFloat(rc.right), rc.bottom);
pRenderTarget->FillRectangle(&rectangle1, pBrush);
}
}

Expand All @@ -1385,7 +1385,7 @@ void SurfaceD2D::FillRectangle(PRectangle rc, Surface &surfacePattern) {
if (SUCCEEDED(hr)) {
ID2D1BitmapBrush *pBitmapBrush = NULL;
D2D1_BITMAP_BRUSH_PROPERTIES brushProperties =
D2D1::BitmapBrushProperties(D2D1_EXTEND_MODE_WRAP, D2D1_EXTEND_MODE_WRAP,
D2D1::BitmapBrushProperties(D2D1_EXTEND_MODE_WRAP, D2D1_EXTEND_MODE_WRAP,
D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR);
// Create the bitmap brush.
hr = pRenderTarget->CreateBitmapBrush(pBitmap, brushProperties, &pBitmapBrush);
Expand Down Expand Up @@ -1469,9 +1469,9 @@ void SurfaceD2D::DrawRGBAImage(PRectangle rc, int width, int height, const unsig
ID2D1Bitmap *bitmap = 0;
D2D1_SIZE_U size = D2D1::SizeU(width, height);
D2D1_BITMAP_PROPERTIES props = {{DXGI_FORMAT_B8G8R8A8_UNORM,
D2D1_ALPHA_MODE_PREMULTIPLIED}, 72.0, 72.0};
D2D1_ALPHA_MODE_PREMULTIPLIED}, 72.0, 72.0};
const HRESULT hr = pRenderTarget->CreateBitmap(size, &image[0],
width * 4, &props, &bitmap);
width * 4, &props, &bitmap);
if (SUCCEEDED(hr)) {
D2D1_RECT_F rcDestination = {rc.left, rc.top, rc.right, rc.bottom};
pRenderTarget->DrawBitmap(bitmap, rcDestination);
Expand Down Expand Up @@ -2840,7 +2840,7 @@ LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam
}

LRESULT PASCAL ListBoxX::StaticWndProc(
HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) {
HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) {
if (iMessage == WM_CREATE) {
CREATESTRUCT *pCreate = reinterpret_cast<CREATESTRUCT *>(lParam);
SetWindowPointer(hWnd, pCreate->lpCreateParams);
Expand Down Expand Up @@ -3035,7 +3035,7 @@ bool Platform::IsDBCSLeadByte(int codePage, char ch) {
case 932:
// Shift_jis
return ((uch >= 0x81) && (uch <= 0x9F)) ||
((uch >= 0xE0) && (uch <= 0xEF));
((uch >= 0xE0) && (uch <= 0xEF));
case 936:
// GBK
return (uch >= 0x81) && (uch <= 0xFE);
Expand All @@ -3048,16 +3048,16 @@ bool Platform::IsDBCSLeadByte(int codePage, char ch) {
case 1361:
// Korean Johab KS C-5601-1992
return
((uch >= 0x84) && (uch <= 0xD3)) ||
((uch >= 0xD8) && (uch <= 0xDE)) ||
((uch >= 0xE0) && (uch <= 0xF9));
((uch >= 0x84) && (uch <= 0xD3)) ||
((uch >= 0xD8) && (uch <= 0xDE)) ||
((uch >= 0xE0) && (uch <= 0xF9));
}
return false;
}

int Platform::DBCSCharLength(int codePage, const char *s) {
if (codePage == 932 || codePage == 936 || codePage == 949 ||
codePage == 950 || codePage == 1361) {
codePage == 950 || codePage == 1361) {
return Platform::IsDBCSLeadByte(codePage, s[0]) ? 2 : 1;
} else {
return 1;
Expand Down
3 changes: 2 additions & 1 deletion scintilla/win32/ScintillaWin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,8 @@ UINT CodePageFromCharSet(DWORD characterSet, UINT documentCodePage) {
}
switch (characterSet) {
case SC_CHARSET_ANSI: return 1252;
case SC_CHARSET_DEFAULT: return documentCodePage ? documentCodePage : 1252;
//case SC_CHARSET_DEFAULT: return documentCodePage ? documentCodePage : 1252; // SCI orig
case SC_CHARSET_DEFAULT: return documentCodePage;
case SC_CHARSET_BALTIC: return 1257;
case SC_CHARSET_CHINESEBIG5: return 950;
case SC_CHARSET_EASTEUROPE: return 1250;
Expand Down
Loading

0 comments on commit c860bc7

Please sign in to comment.