Skip to content

Commit

Permalink
Support bidirectional for Arabic and Hebrew.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Jul 28, 2018
1 parent b7ad639 commit ef9fe08
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ extern BOOL bFixLineEndings;
extern BOOL bAutoStripBlanks;

extern int iRenderingTechnology;
extern int iBidirectional;
// Default Codepage and Character Set
extern int iDefaultCodePage;
//extern int iDefaultCharSet;
Expand Down Expand Up @@ -84,6 +85,7 @@ HWND EditCreate(HWND hwndParent) {
NULL);

SendMessage(hwnd, SCI_SETTECHNOLOGY, iRenderingTechnology, 0);
SendMessage(hwnd, SCI_SETBIDIRECTIONAL, iBidirectional, 0);
SendMessage(hwnd, SCI_SETCODEPAGE, iDefaultCodePage, 0);
SendMessage(hwnd, SCI_SETEOLMODE, SC_EOL_CRLF, 0);
SendMessage(hwnd, SCI_SETPASTECONVERTENDINGS, 1, 0);
Expand Down
14 changes: 14 additions & 0 deletions src/Notepad2.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ BOOL bAlwaysOnTop;
BOOL bMinimizeToTray;
BOOL bTransparentMode;
int iRenderingTechnology;
int iBidirectional;
BOOL bShowToolbar;
BOOL bShowStatusbar;

Expand Down Expand Up @@ -1423,6 +1424,7 @@ LRESULT MsgCreate(HWND hwnd, WPARAM wParam, LPARAM lParam) {
InitScintillaHandle(hwndEdit);

iRenderingTechnology = (int)SendMessage(hwndEdit, SCI_GETTECHNOLOGY, 0, 0);
iBidirectional = (int)SendMessage(hwndEdit, SCI_GETBIDIRECTIONAL, 0, 0);

SendMessage(hwndEdit, SCI_SETZOOM, iZoomLevel, 0);
// Tabs
Expand Down Expand Up @@ -2254,6 +2256,8 @@ void MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam) {

i = IDM_SET_RENDER_TECH_DEFAULT + iRenderingTechnology;
CheckMenuRadioItem(hmenu, IDM_SET_RENDER_TECH_DEFAULT, IDM_SET_RENDER_TECH_D2DDC, i, MF_BYCOMMAND);
i = IDM_SET_BIDIRECTIONAL_NONE + iBidirectional;
CheckMenuRadioItem(hmenu, IDM_SET_BIDIRECTIONAL_NONE, IDM_SET_BIDIRECTIONAL_R2L, i, MF_BYCOMMAND);

CheckCmd(hmenu, IDM_VIEW_NOSAVERECENT, bSaveRecentFiles);
CheckCmd(hmenu, IDM_VIEW_NOSAVEFINDREPL, bSaveFindReplace);
Expand Down Expand Up @@ -4136,6 +4140,13 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) {
iRenderingTechnology = (int)SendMessage(hwndEdit, SCI_GETTECHNOLOGY, 0, 0);
break;

case IDM_SET_BIDIRECTIONAL_NONE:
case IDM_SET_BIDIRECTIONAL_L2R:
case IDM_SET_BIDIRECTIONAL_R2L:
SendMessage(hwndEdit, SCI_SETBIDIRECTIONAL, LOWORD(wParam) - IDM_SET_BIDIRECTIONAL_NONE, 0);
iBidirectional = (int)SendMessage(hwndEdit, SCI_GETBIDIRECTIONAL, 0, 0);
break;

case IDM_VIEW_SHOWFILENAMEONLY:
iPathNameFormat = 0;
lstrcpy(szTitleExcerpt, L"");
Expand Down Expand Up @@ -5349,6 +5360,8 @@ void LoadSettings(void) {

iRenderingTechnology = IniSectionGetInt(pIniSection, L"RenderingTechnology", 0);
iRenderingTechnology = clamp_i(iRenderingTechnology, SC_TECHNOLOGY_DEFAULT, SC_TECHNOLOGY_DIRECTWRITEDC);
iBidirectional = IniSectionGetInt(pIniSection, L"Bidirectional", 0);
iBidirectional = clamp_i(iBidirectional, SC_BIDIRECTIONAL_DISABLED, SC_BIDIRECTIONAL_R2L);

IniSectionGetString(pIniSection, L"ToolbarButtons", L"", tchToolbarButtons, COUNTOF(tchToolbarButtons));

Expand Down Expand Up @@ -5580,6 +5593,7 @@ void SaveSettings(BOOL bSaveSettingsNow) {
IniSectionSetBool(pIniSection, L"MinimizeToTray", bMinimizeToTray);
IniSectionSetBool(pIniSection, L"TransparentMode", bTransparentMode);
IniSectionSetInt(pIniSection, L"RenderingTechnology", iRenderingTechnology);
IniSectionSetInt(pIniSection, L"Bidirectional", iBidirectional);
Toolbar_GetButtons(hwndToolbar, IDT_FILE_NEW, tchToolbarButtons, COUNTOF(tchToolbarButtons));
IniSectionSetString(pIniSection, L"ToolbarButtons", tchToolbarButtons);
IniSectionSetBool(pIniSection, L"ShowToolbar", bShowToolbar);
Expand Down
6 changes: 6 additions & 0 deletions src/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,12 @@ BEGIN
MENUITEM "Direct2D Retain", IDM_SET_RENDER_TECH_D2DRETAIN
MENUITEM "Direct2D GDI DC", IDM_SET_RENDER_TECH_D2DDC
END
POPUP "Bidirectional"
BEGIN
MENUITEM "None", IDM_SET_BIDIRECTIONAL_NONE
MENUITEM "Left to Right", IDM_SET_BIDIRECTIONAL_L2R
MENUITEM "Right to Left", IDM_SET_BIDIRECTIONAL_R2L
END
MENUITEM SEPARATOR
MENUITEM "Single &File Instance", IDM_VIEW_SINGLEFILEINSTANCE
MENUITEM "File &Change Notification...\tAlt+F5", IDM_VIEW_CHANGENOTIFY
Expand Down
3 changes: 3 additions & 0 deletions src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,9 @@
#define IDM_SET_RENDER_TECH_D2D 40049
#define IDM_SET_RENDER_TECH_D2DRETAIN 40050
#define IDM_SET_RENDER_TECH_D2DDC 40051
#define IDM_SET_BIDIRECTIONAL_NONE 40060
#define IDM_SET_BIDIRECTIONAL_L2R 40061
#define IDM_SET_BIDIRECTIONAL_R2L 40062

#define IDM_LANG_DEFAULT 41000
#define IDM_LANG_NULL 41060
Expand Down

0 comments on commit ef9fe08

Please sign in to comment.