ProgerXP / Notepad2e

Word highlighting, simultaneous editing, split views, math evaluation, un/grep, comment reformatting, UAC elevation, complete regexps (PCRE), Lua lexers, DPI awareness and more (XP+)
Other
373 stars 52 forks source link

Code Review For dev Merge #118

Closed ProgerXP closed 6 years ago

ProgerXP commented 7 years ago
  1. Replace tabs with spaces everywhere. >Done
  2. Remove file footers (/// End of Foo.c \\\, // End of Foo.c).
    >Done
  3. Ensure all text files (any extension) end with a new line (as in POSIX). >Done
  4. Is printtime.bat used anywhere? >The bat-file is used to generate _version.h which contains build time shown in the About dialog.
  5. Why some 2e-specific functions don't have prefixes? In EditHelper.h and elsewhere. >Done. The point here was to rename the functions which are directly called from the N2-code.
  6. Are you using some C++ features in EditHelperEx.cpp? >Yes. There are just few cases where C++ code is urgently needed: COM for showing system context menu, regex-validation function. Some other functions may be added in order to avoid duplication of code.
  7. Why comments in ExtSelection.c have 50+ space characters? >Done
  8. nn2e_SelectionNotificationHandler - "nn"? >Done

Dialogs.c

  1. Why does _version.h contain a date of 12-May-16 10:54:02.01? The UI shows correct date. Is it unused? > printtime.bat file is automatically executed when building the project to generate _version.h which contains actual build time shown in the About dialog. _version.h file removed from the sources.

  2. It seems IDC_EMAIL was renamed to IDC_MAIL (AboutDlgProc) - if so then why? >Done

  3. There were LVS_EX_FULLROWSELECT commented out in FavoritesDlgProc, FileMRUDlgProc, SelectEncodingDlgProc - bring it back, I want to try them. >Done

  4. Do you know what SetExplorerTheme(GetDlgItem(hwnd,IDC_FILEMRU)); was supposed to do? > There was some kind of Explorer-like visual customization. Here are some details on it: https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/1e861d81-c15e-4453-a907-ddce96e8b313/using-setwindowtheme-to-customize-the-look-of-an-application-explorer-theme-is-widely-discussed?forum=windowsuidevelopment

  5. What this commented out block was supposed to do?

    case LVN_GETDISPINFO: 
    ///* was commented out
    LV_DISPINFO *lpdi = (LPVOID)lParam;
    if (lpdi->item.mask & LVIF_IMAGE) 
    WCHAR tch[MAX_PATH];
    LV_ITEM lvi;
    SHFILEINFO shfi;
    DWORD dwFlags = SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED;
    DWORD dwAttr  = 0;
    ZeroMemory(&lvi,sizeof(LV_ITEM));
    lvi.mask = LVIF_TEXT;
    lvi.pszText = tch;
    lvi.cchTextMax = COUNTOF(tch);
    lvi.iItem = lpdi->item.iItem;
    ListView_GetItem(GetDlgItem(hwnd,IDC_FILEMRU),&lvi);
    if (!PathFileExists(tch)) 
      dwFlags |= SHGFI_USEFILEATTRIBUTES;
      dwAttr = FILE_ATTRIBUTE_NORMAL;
      shfi.dwAttributes = 0;
      SHGetFileInfo(PathFindFileName(tch),dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags);
    else 
      shfi.dwAttributes = SFGAO_LINK | SFGAO_SHARE;
      SHGetFileInfo(tch,dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags);
    lpdi->item.iImage = shfi.iIcon;
    lpdi->item.mask |= LVIF_DI_SETITEM;
    lpdi->item.stateMask = 0;
    lpdi->item.state = 0;
    if (shfi.dwAttributes & SFGAO_LINK) 
      lpdi->item.mask |= LVIF_STATE;
      lpdi->item.stateMask |= LVIS_OVERLAYMASK;
      lpdi->item.state |= INDEXTOOVERLAYMASK(2);
    if (shfi.dwAttributes & SFGAO_SHARE) 
      lpdi->item.mask |= LVIF_STATE;
      lpdi->item.stateMask |= LVIS_OVERLAYMASK;
      lpdi->item.state |= INDEXTOOVERLAYMASK(1);
    dwAttr = GetFileAttributes(tch);
    if (!flagNoFadeHidden &&
        dwAttr != INVALID_FILE_ATTRIBUTES &&
        dwAttr & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) 
      lpdi->item.mask |= LVIF_STATE;
      lpdi->item.stateMask |= LVIS_CUT;
      lpdi->item.state |= LVIS_CUT;
    //*/

    >It looks like MRU's list control was originally developed as a virtual one with providing of the item's icons using this code. Absolutely the same code is now used in FileMRUIconThread().

  6. Why n2e_OpenMRULast is in Dialogs.c, not inside Extended\? It doesn't seem to use any internal fields. >Done

    Edit.c

  7. Do you know why encodings such as JIS, EUC, GC2312 were commented out and removed? >N/A

  8. Can you remind me why do we need new adjustNewLines parameter for EditGetClipboardText? >Removed adjustNewLines parameter during code cleanup. Retrieving of the clipboard text without adjustments is no longer required.

  9. You haven't removed one WARN() call (you have removed others). >Done

  10. remove_char and FindEditWndProc should be in 2e-specific helpers? >Done

  11. Most of IDACC_BACK handling (between Dlg functions) can and should be moved into a 2e function. >Done

  12. Most of WM_COMMAND handling in EditInsertTagDlgProc should be moved into a 2e function. >Done

  13. Why would Flo need SciThemedWndProc and other removed functions at the end of Edit.c? >N/A. There was some kind of Explorer-like visual customization. Here are some details on it: https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/1e861d81-c15e-4453-a907-ddce96e8b313/using-setwindowtheme-to-customize-the-look-of-an-application-explorer-theme-is-widely-discussed?forum=windowsuidevelopment

  14. Insert short info comments of form // [2e] (or /* likewise) before changes from the original code. It should tell the feature's name (e.g. Edit > Go to last change) and/or description of the code change/purpose and/or the #issue number (e.g. for directory lock issue). No need to insert comments before: commented out blocks that you have removed, non-functional changes (NULL -> L"", replacing a call with an equivalent 2e function, 'if' -> '?:', etc.), code that was replaced with a single call to a function starting with n2e_ or N2E_ (this is because the modification is clear), new declarations in *.h and #inclusions in h/c that start with n2e_ prefix, minor edits (e.g. added parameter(s) to a modified function). If more than one line was changed, then the block should be closed off with [/2e] comment. To determine changed blocks you can use my normalized sources. >Done

  15. may be i need to doesn't read like proper English. >Removed

Notepad2.c

  1. OnPaneSizeClick: is it possible to get rid of the timer and use right-click instead of double-click for copy-to-clipboard? >Done
  2. Instead of splitting code into n2e_MsgCreate which is almost identical to the original make a new function within Notepad2.c like you did with FileLoad <-> _FileLoad so it doesn't break the diff. >Done
  3. Why GetCurrentShowTitleMenuID and GetCurrentLanguageIndicatorMenuID are not in 2e utils? >Done
  4. Rename "hilite" to "highlight" everywhere in the original code (no need to [2e]-comment this). >Done
  5. ID_BLOCK_UNWRAPQUOTESATCURSOR is complimenting ID_BLOCK_UNWRAPSELECTION, no need to add "ATCURSOR". >Done
  6. What is the purpose of this block?
    case IDT_SETTINGS_SAVE_ON_EXIT:
    if (IsCmdEnabled(hwnd, IDM_VIEW_SAVESETTINGS_MODE_ALL))
    SendMessage(hwnd, WM_COMMAND, MAKELONG(IDM_VIEW_SAVESETTINGS_MODE_ALL, 1), 0);
    else
    MessageBeep(0);
    break;

    >There should be a system beep(instead of save) when clicking on a toolbar button 'Save settings on Exit' if application was executed without ini-file. The case is not available now because this toolbar button is disabled when 'save settings'-command is forbidden.

  7. Move autoclosing tag handling to a 2e function (// Auto close tags) and reuse it in Edit.c's EditInsertTagDlgProc instead of the serious code duplication. >Done
  8. Rename SSM_REGULAR to SSM_ALL since it really saves all settings. >Done
  9. Why using magic constants in IsExpressionEvaluationEnabled and GetExpressionTextRange? >Done
  10. int2bin and two functions after it should be moved to 2e utils. >Done
  11. The big block in UpdateStatusbar should be made a 2e function. >Done
  12. Replace hardcoded string in nid.szTip with WC_NOTEPAD2. >Done

Notepad2.rc

  1. Add &accel chars:
    
    Open Next (&1)
    Open Previous (&2)
    &Rename To
    &Shell Menu

Wrap &Selection Unwrap Bra&ckets Unwrap &Quotes

Str&ip HTML Tags Escape HTML Ta&gs St&ring To Hex Hex To Stri&ng

Highlight Curren&t Word

Evaluate Math E&xpressions

&Ctrl+Arrow Navigation &Ctrl+Wheel Scroll

**>Done**
1. Rename `Escape HTML` -> `Escape HTML Tags`.
**>Done**
1. What are `qqqqqqqqqqqqqqqqqq` in `IDD_ABOUT DIALOGEX`?
**>Placeholder strings. Replaced with current values.**
1. Change `IDS_APPTITLE_PASTEBOARD` to `Notepad 2e (Paste Board)`.
**>Done**
1. In the about dialog, remove version from the first label (`Notepad 2e 4.2.25`) and insert a new label (same style as the copyright) saying `Based on Notepad2 4.2.25` and shift down other labels.  
**>Done**
1. Ensure modifiers in all hotkeys are constructed as `Ctrl+Alt+Shift+X` (currently the order of modifiers differs in different menu items).
**>Done**

### Styles.c

Notepad2 doesn't and won't have code folding, what this code block is for?
```C
// set folding style; braces are for scoping only
static const int iMarkerIDs[] = 
    SC_MARKNUM_FOLDEROPEN,
    SC_MARKNUM_FOLDER,
    SC_MARKNUM_FOLDERSUB,
    SC_MARKNUM_FOLDERTAIL,
    SC_MARKNUM_FOLDEREND,
    SC_MARKNUM_FOLDEROPENMID,
    SC_MARKNUM_FOLDERMIDTAIL
;
COLORREF clrFore = SciCall_StyleGetFore(STYLE_DEFAULT);
COLORREF clrBack = SciCall_StyleGetBack(STYLE_DEFAULT);
SciCall_SetFoldMarginColour(TRUE, clrBack);
SciCall_SetFoldMarginHiColour(TRUE, clrBack);
// Set marker color to the average of clrFore and clrBack
clrFore = (((clrFore & 0xFF0000) + (clrBack & 0xFF0000)) >> 1 & 0xFF0000) |
  (((clrFore & 0x00FF00) + (clrBack & 0x00FF00)) >> 1 & 0x00FF00) |
  (((clrFore & 0x0000FF) + (clrBack & 0x0000FF)) >> 1 & 0x0000FF);
// Rounding hack for pure white against pure black
if (clrFore == 0x7F7F7F)
  clrFore = 0x808080;
for (i = 0; i < COUNTOF(iMarkerIDs); ++i)
  SciCall_MarkerSetBack(iMarkerIDs[i], clrFore);
  SciCall_MarkerSetFore(iMarkerIDs[i], clrBack);

>The code was added back in 2013 (https://github.com/ProgerXP/Notepad2e/commit/a03ee65020565029df463072c689625c7d687aca). I've found no difference after removing the block in my local tests and see no reason to preserve it.

ProgerXP commented 7 years ago

Additional notes regarding files in Extension.

  1. Check newly added operations (str2hex, etc.) if they can operate on rectangular selection. Most don't; for them add IsSelectionModeValid which will produce a MsgBox. >Done. In addition IsSelectionModeValid became to n2e_ShowPromptIfSelectionModeIsRectangle to make the code clear.
  2. Why some N2E_Trace are protected by _DEBUG but some are not? This needs to be uniformized; if you do limit tracing to debug builds then all trace calls should be protected. Perhaps better way is not to protect trace calls but trace functions (in Utils.c) themselves like it's done for trace macros. And move all logging/tracing to a separate .c/.h. >Done. Direct N2E_Trace()-calls were replaced with corresponding TRACE-macroses. Tracing subroutines changed to be completely "debug only" (as it was originally designed).
  3. Do you really need all externs and inclusions in *.h or they were just copy pasted? >Finished with a cleanup for includes/extern references.
  4. From what I understand, you do not prefix variables internal to a .c file with n2e_ or n2e. Then why some units have them all prefixed? >n2e-prefix is excess for the code isolated in separate 2E-modules (Extension folder). Originally, these names came from other developer(s) and now they were changed to comply common naming style.
  5. Was the large header comment in SciCall.c written by you? If yes then remove it since no other files have it. >It looks like SciCall.h came from another project notepad2-mod https://github.com/XhmikosR/notepad2-mod/commit/d6a6f3a6e1e33d4545223793388255d18aa81bf4#diff-4d4c7049a418e672be3d54e61d768b7f

EditHelper.c

  1. Escape HTML should preserve selection unless original selection was empty. >Done
  2. Is else missing between } and {? If not then why a block is needed here?
    if (skipcl)
    {
    int ti = 0;
    for (; ti < skipcl; ++ti)
    {
      if (tchl - _left_braces == skipl[ti])
      {
        N2E_TRACE("Skipped braces pair found '%c'", *tchl);
        skipl[ti] = -1;
        goto NEXT;
      }
    }
    }                       <<    
    {                       <<
    N2E_TRACE("Left bracket found '%c'", lch);
    break;
    }

    >No, there is no missing else-statement. Removed excess brackets.

ExtSelection.c

  1. "When one match one document" - what does it mean? > Only single word in the document matches selection.
  2. Explain "SE mode" in the comment. >Rephrased comments for indicators: //multiple words matches selection, some are located on other pages

    define N2E_SELECT_INDICATOR 9

    //single word matches

    define N2E_SELECT_INDICATOR_SINGLE 10

    //multiple words matches selection, all are visible on current page

    define N2E_SELECT_INDICATOR_PAGE 11

    // "selection edit"-mode, Ctrl+Tab to activate

    define N2E_SELECT_INDICATOR_EDIT 12**

  3. total count ' - why apostrophe? > Count-postfix added to corresponding variable name, useless comment removed.
  4. Is icase_compare used anywhere? >Removed.
  5. Why to_lower uses hardcoded Russian char references? Why cannot it use a Unicode function? >Removed useless to_lower.
  6. Why Shift has special processing?
    if (VK_RETURN == key && GetKeyState(VK_SHIFT) >= 0)

    >Shift-specific code was already removed during bug fixing for "new line"-commands.

  7. Why do you do this in n2e_SelectionInit? iHighlightLineIfWindowInactive, iWordNavigationMode do not belong here.
    SendMessage(hwndEdit, SCI_SETCARETLINEVISIBLEALWAYS, iHighlightLineIfWindowInactive, 0);
    SendMessage(hwndEdit, SCI_SETWORDNAVIGATIONMODE, iWordNavigationMode, 0);

    >n2e_SelectionInit renamed to n2e_EditInit to change its sense.

  8. Need to refactor 4 duplicated blocks in n2e_SelectionInit. >Done. Added n2e_EditSelectionInit()-subroutine.
  9. Correct English and/or meaning.
    then we must don't check next matches
    Anyhow HL_SELECT_INDICATOR must be there ?!?!

    >Removed useless comments.

  10. Replace all ?!?! and ??????? with !. >Done.

StrToHex.c

Write unit tests that:

Write same tests for upcoming Base64 (#122) and QP (#124). >Done.

Utils.c

  1. What is n2e_SelEditTimerProc for? >Already removed
  2. Replace magic strings from the previous developer with #constants. >Done. 1, In n2e_EnumProc, instead of searching window title for substring (!!!) check its class as in EnumWndProc. >Done. Notepad2e windows are searched by window class prefix since different execution types (e.g. elevated, pasteboarded) affects the classname postfix.
  3. Rename HWM_RELOAD_SETTINGS to WM_N2E_RELOAD_SETTINGS. >Done.
  4. Change value of HWM_RELOAD_SETTINGS to WM_USER + 0xFF and of N2E_WHEEL_TIMER_ID to 0xFF. >Done.
  5. Shouldn't isspace be iswspace instead (same with strchr/wcschr, etc.)? >Fixed. Additionally, n2e_IsSpace is defined but used in just 1 place; calls to common functions like these should be normalized. >Done.
  6. In n2e_OFNHookProc, why return/break are positioned so weirdly? >Fixed.
  7. Why NULL != StrChr(L"_", ch) instead of simple comparison? >Done.
  8. Notepad2.c has more than 10 identical long calls to SetWindowTitle; they need to be moved into a short function that will collect arguments itself. This will also remove the need for ugly SaveWindowTitleParams and UpdateWindowTitle. >Done. n2e_UpdateWindowTitle()-calls are used everywhere.
ProgerXP commented 7 years ago

Other files

Why/Do we need lexlink.js, Notepad2.vcproj/vcxproj/vcxproj.filters, Notepad2e.vcxproj, Notepad2e_vs2015.sln, vs2015_notepad2e.vssettings, wdkbuild\?

1. lexlink.js came from original sources. There is a description in the Readme.txt that this file can be used as a part of updating process of the set of supported lexer schemes (mentioned as LinkLex.js). Retained. 2. Removed vcxproj.filters. 3. Notepad2e.vcxproj - is a VS2015 project file. Retained. 4. Removed Notepad2e_vs2015.sln. 5. vs2015_notepad2e.vssettings - contains approved text formatting settings, should be used to adjust VS2015 text editor when starting work with project sources. Retained. 6. wdkbuild\ folder came from original sources. Readme.txt states wdkbuild's scripts can be used to build compact executable program file using Windows Driver Kit tools. Retained.

cshnik commented 7 years ago

Please see my comments >inline.

ProgerXP commented 7 years ago

Please see my comments >inline.

Comments where? Understood.

ProgerXP commented 7 years ago
  1. Why some 2e-specific functions don't have prefixes? In EditHelper.h and elsewhere.

Done. The point here was to rename the functions which are directly called from the N2-code.

All functions and other symbols that are exported (in .h) should have the prefix. Symbols only used inside .c/pp don't have to have the prefix. >Done.

ProgerXP commented 7 years ago

LVS_EX_FULLROWSELECT for FavoritesDlgProc, FileMRUDlgProc, SelectEncodingDlgProc

Yes, this feels definitely better than without full row select. What other listviews we have that don't have this style? > Added the same style to: 1. OpenWithDlgProc, "Open with..." dialog, Alt+L 2. Style_SelectLexerDlgProc, "Syntax Scheme" dialog, F12

ProgerXP commented 6 years ago

Old issues

Replace tabs with spaces everywhere.

Tabs are still left in many c/h files for alignment. Please replace them with spaces.

> Fixed.

Ensure all text files (any extension) end with a new line (as in POSIX).

Add to Notepad2.ver and to printtime.bat too.

> Fixed.

Rename "hilite" to "highlight" everywhere in the original code (no need to [2e]-comment this).

I can see IDM_VIEW_HILITECURRENTLINE in resource.h but I cannot find where it's used. Is it unused?

> Removed unused identifiers.

Move autoclosing tag handling to a 2e function (// Auto close tags) and reuse it in Edit.c's EditInsertTagDlgProc instead of the serious code duplication.

Didn't help at all. At least let's move checking for tags that shouldn't be closed into a separate function (currently it tests for 2 different sets of tags even though logically these sets must be the same).

> Done. n2e_IsValidClosingTagA/n2e_IsValidClosingTagW functions implemented.

In the about dialog, remove version from the first label (Notepad 2e 4.2.25) and insert a new label (same style as the copyright) saying Based on Notepad2 4.2.25 and shift down other labels.

The first label should have a space before "2e":

    LTEXT           "Notepad2e",IDC_VERSION,42,7,174,8

> Fixed.

Notepad2 doesn't and won't have code folding, what this code block is for?

The code was added back in 2013 (a03ee65). I've found no difference after removing the block in my local tests and see no reason to preserve it.

I agree.

The first block should be partially removed (// Code folding until /2e) - let's keep SCLEX_NSIS and SCLEX_CSS branches.

The second block about folding should be removed entirely (// set folding style until /2e).

> Done.

Write same tests for upcoming Base64 (#122) and QP (#124).

Done.

Were Base64 and QP implemented already or only test cases are available at the moment? If not how much time they will take (they should have libraries already, both are standard algorithms)? **> 1. Only test cases were implemented for these encoding types.

  1. RFC-compliant implementation for encodings will take up to 3-6 hours for QP and 6-10 hours for Base64.**

There is another option for Base64: we can use one of the next available open source implementations: http://web.mit.edu/freebsd/head/contrib/wpa/src/utils/base64.c https://opensource.apple.com/source/QuickTimeStreamingServer/QuickTimeStreamingServer-452/CommonUtilitiesLib/base64.c http://libb64.sourceforge.net/ These were listed here: https://stackoverflow.com/questions/342409/how-do-i-base64-encode-decode-in-c Please check if license types are appropriate for this project and confirm we can use one of these implementations. Do we need to proceed on implements for these encodings in the current phase?

Were any bugs uncovered by the tests for str2hex and back? > The only bug was found when using small buffer size (provided by test case) within encoding procedure for utf-8 text. This buffer transition problem was fixed.

New issues

1.

Done. In addition IsSelectionModeValid became to n2e_ShowPromptIfSelectionModeIsRectangle to make the code clear.

In Edit.c, previously there were lines line this:

void EditChar2Hex(HWND hwnd) {
  if (!IsSelectionModeValid(hwnd))
    return;

Now the function call was removed and it's like this:

void EditChar2Hex(HWND hwnd) {
  if (SC_SEL_RECTANGLE != SendMessage(hwnd, SCI_GETSELECTIONMODE, 0, 0)) 
    ...
  else
    MsgBox(MBINFO, IDS_SELRECT);
}

It seems the old Notepad2 code was restored, why?

This is what the new n2e_ShowPromptIfSelectionModeIsRectangle function is supposed to do.

> Fixed. All original selection mode checks with MsgBox for non-rectangle selection were replaced with n2e_ShowPromptIfSelectionModeIsRectangle()-calls. While primary thought was to keep as much of original code as possible.

  1. Remind me, which issue is this change from, in EditModifyLines?
// old
        iPos = (int)SendMessage(hwnd, SCI_POSITIONFROMLINE, (WPARAM)iLine, 0);
// new
        iPos = (int)SendMessage(hwnd, SCI_GETLINEENDPOSITION, (WPARAM)iLine, 0);

> Fixed. Rollback was applied for this change. The bug was introduced during code cleanup (looks like misspelling or copy-paste).

  1. You have been using this form:
// [2e]: Save/Save To - file extension #17

However, in some places you have forgotten the colon which needs to be corrected. Example:

// [2e] Edit initialization subroutine

Or the colon should be removed from anywhere. Make it uniform.

> Fixed. Now "[2e]:"-prefix is applying everywhere.

  1. What is this new semicolon for?
INT_PTR CALLBACK EditInsertTagDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) {
...
};

> Fixed. Removed useless semicolon.

  1. A comment in Notepad2.c has wrong indentation:
      break;

      // Newline with toggled auto indent setting
    case CMD_CTRLENTER:

> Fixed.

  1. Is this character case intentional?
// StrToHex.h
#include <WTypes.h>

> Recent check allowed to get rid of this include from StrToHex.h. There is no case sensitivity when including header files in Windows. But usually include filename came from MSDN documentation where CamelCase is used, e.g.: https://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx

  1. What's up with the coding style in Trace.h? It uses tabs instead of spaces, its lines are 150+ characters long and its columns are randomly surrounded by spaces (i.e. some are, some are not).
#define N2E_TRACE_TR(OBJ)               n2e_Trace ... , #OBJ , OBJ.chrg.cpMin ,OBJ.chrg.cpMax ,OBJ.lpstrText );

> Fixed.

  1. Missing [2e] comments from:
  1. What is the meaning of this addition to Edit.c?
        case IDC_LINENUM:
          if (EN_CHANGE == HIWORD(wParam))
          {
          }
          break;
        case IDC_COLNUM:
          if (EN_CHANGE == HIWORD(wParam))
          {
          }
          break;
        case IDC_POSNUM:
          if (EN_CHANGE == HIWORD(wParam))
          {
          }
          break;

> Removed useless code.

  1. This handler in Notepad2.c was added but it seems to be unused (empty). If so it should be removed, and two [2e] comment blocks can be merged then.
    // [2e]: Edit highlighted word #18
    case WM_ACTIVATEAPP:
      if (!wParam)
       n2e_SelectionEditStop(SES_APPLY);
      break;
    // [/2e]
    case WM_KEYDOWN:                    <<<
      break;                            <<<
    // [2e]: Edit highlighted word #18
    case WM_MOUSEACTIVATE:
      n2e_SelectionEditStop(SES_APPLY);
      return DefWindowProc(hwnd, umsg, wParam, lParam);
    // [/2e]

> Fixed.

  1. A comment in Notepad2.c is misaligned:
    // [2e]: "Recall previous" command
    case ID_FILE_OPENPREVIOUS:
      if (MRU_Enum(pFileMRU, 0, NULL, 0) > 0)
        if (FileSave(FALSE, TRUE, FALSE, FALSE, FALSE))
          WCHAR tchFile[MAX_PATH];
          if (n2e_OpenMRULast(tchFile))
            _FileLoad(TRUE, FALSE, FALSE, FALSE, tchFile, TRUE);
      break;
      // [/2e]                <<<
    case IDM_FILE_EXIT:

> Fixed.

cshnik commented 6 years ago

Please answer the questions marked as "TODO".

ProgerXP commented 6 years ago

Tabs are still left in many c/h files for alignment. Please replace them with spaces.

Still present in Notepad2eTests/TextEncodingTests.cpp.

> Fixed.

There is another option for Base64: we can use one of the next available open source implementations: http://web.mit.edu/freebsd/head/contrib/wpa/src/utils/base64.c http://libb64.sourceforge.net/

First uses BSD, same kind of license as Notepad2, second is in public domain. We can take any of the two that you think is better.

Do we need to proceed on implements for these encodings in the current phase?

Yes.

> Base64 implemented.

Dialogs.c: WM_INITDIALOG (simply put a line at the beginning of the case)

TODO: Please clarify this point.

INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
  static HFONT hFontTitle;
  switch (umsg)
    // [2e]: Updated with Notepad 2e info  <<<
    case WM_INITDIALOG:

> Fixed.

ProgerXP commented 6 years ago

File tree reorganization

  1. Rename Notepad2eTests to test and place all 2e-specific tests under a subfolder (test\Extension). Place test data (txt) into test\data\Extension\[StrToHex]. > Done.
  2. Does the StrToHex folder also contain QP and B64 tests? If so the folder should be renamed or the files should be moved into separate folders. > StrToHex folder contained test file samples and was shared for all tests (StrToHex/QP/B64). These files moved to test\data\Extension\.
  3. Need to remove bin\Notepad2.ini as it's a new file, original ini is in the project's root. Please review your changes to this file (https://github.com/ProgerXP/Notepad2e/commits/dev/bin/Notepad2.ini) and apply them to \Notepad2.ini, then remove the second ini. > Done.
  4. Remove all exe's and Win32 folder from the repo. Place new builds (Release profile) into bin\Notepad2e.exe. > Done.
  5. I see two *.sln files - 2 and 2e. The first was changed 4 years ago, I believe it can be removed? > Removed Notepad2.sln.
ProgerXP commented 6 years ago

dev is ready for merge. I'd like you to fix a possible bug in #124 before doing this, then merge dev into master and delete dev.

ProgerXP commented 6 years ago

At last we did it.

ProgerXP commented 6 years ago

It seems I was too fast to close this issue.

  1. In src/Extension/Utils.c, why some IniSetInt lines are using literal strings while others are using constants (there are consts for these strings as well)? Correct it please. > Done.
  2. Is it absolutely necessary to copy the whole mEncoding array into Externals.c from Edit.c? Try reusing it. > The proper way to prevent code duplication for mEncoding array is to move it out to a separate module which can be used in both projects (Notepad2e and Notepad2eTests) simultaneously. Current implementation does not allow to reference to an instance within Edit.c because this module is heavily attached to Notepad2e project internals and can't be directly included in Notepad2eTests project. Here are some points regarding the current implementation:
    • Original point was to keep the code as close to original as possible, Edit.c has no sensible changes related to module reorganization or variable movement.
    • mEncoding array contains a set of specific parameters which are required for text recoding procs only (within Notepad2eTests project).
    • Changes to mEncoding array within Notepad2eTests project can be required only when new tests will be implemented related to specific encoding types. Please confirm if we still need to get rid of specified code duplication.
  3. Add colon in the message when a file not found when opening by prefix:
                                                             this colon - v
    Additionally, no file name starting with this string exists in this folder:

    > Done.

ProgerXP commented 6 years ago

Changes to mEncoding array within Notepad2eTests project can be required only when new tests will be implemented related to specific encoding types.

I didn't notice #ifdef N2E_TESTING. Then it's not necessary but please add a comment to Externals.c linking to my comment (https://github.com/ProgerXP/Notepad2e/issues/118#issuecomment-353869333) in case of future questions.