+chg: try to speed-up large file loading

This commit is contained in:
METANEOCORTEX\Kotti 2023-07-11 17:23:42 +02:00
parent 7242a5f4f6
commit d796c33ccf
6 changed files with 69 additions and 49 deletions

View File

@ -404,6 +404,18 @@ void EditInitWordDelimiter(HWND hwnd)
//
extern bool s_bFreezeAppTitle;
static void _PrepareDocBuffer(HWND hwnd)
{
SciCall_Cancel();
SciCall_SetReadOnly(FileWatching.MonitoringLog);
EditClearAllBookMarks(hwnd);
EditClearAllOccurrenceMarkers(hwnd);
SciCall_SetScrollWidth(1);
SciCall_SetXOffset(0);
FileVars_Apply(&Globals.fvCurFile);
Sci_SetWrapModeEx(SC_WRAP_NONE);
}
void EditSetNewText(HWND hwnd, const char* lpstrText, DocPosU lenText, bool bClearUndoHistory, bool bReload)
{
if (!lpstrText) {
@ -416,25 +428,21 @@ void EditSetNewText(HWND hwnd, const char* lpstrText, DocPosU lenText, bool bCle
EditToggleView(hwnd);
}
if (bClearUndoHistory) {
if (Flags.bHugeFileLoadState)
{
UndoRedoReset();
_PrepareDocBuffer(hwnd);
EditSetDocumentBuffer(lpstrText, lenText, bReload);
}
else {
if (bClearUndoHistory) {
UndoRedoReset();
}
_PrepareDocBuffer(hwnd);
UndoTransActionBegin();
EditSetDocumentBuffer(lpstrText, lenText, bReload);
EndUndoTransAction();
}
UndoTransActionBegin();
SciCall_Cancel();
SciCall_SetReadOnly(FileWatching.MonitoringLog);
EditClearAllBookMarks(hwnd);
EditClearAllOccurrenceMarkers(hwnd);
SciCall_SetScrollWidth(1);
SciCall_SetXOffset(0);
FileVars_Apply(&Globals.fvCurFile);
EditSetDocumentBuffer(lpstrText, lenText, bReload);
EndUndoTransAction();
s_bFreezeAppTitle = false;
}

View File

@ -1073,7 +1073,6 @@ extern "C" bool FileVars_GetFromData(const char* lpData, size_t cbData, LPFILEVA
//
extern "C" bool FileVars_Apply(LPFILEVARS lpfv)
{
int const _iTabWidth = (lpfv->mask & FV_TABWIDTH) ? lpfv->iTabWidth : Settings.TabWidth;
SciCall_SetTabWidth(_iTabWidth);
@ -1087,9 +1086,8 @@ extern "C" bool FileVars_Apply(LPFILEVARS lpfv)
SciCall_SetTabIndents(_bTabIndents);
SciCall_SetBackSpaceUnIndents(Settings.BackspaceUnindents);
bool const bWordWrap = (lpfv->mask & FV_WORDWRAP) ? lpfv->bWordWrap : Settings.WordWrap;
int const iWrapMode = bWordWrap ? ((Settings.WordWrapMode == 0) ? SC_WRAP_WHITESPACE : SC_WRAP_CHAR) : SC_WRAP_NONE;
SciCall_SetWrapMode(iWrapMode);
Globals.fvCurFile.bWordWrap = (lpfv->mask & FV_WORDWRAP) ? lpfv->bWordWrap : Settings.WordWrap;
Sci_SetWrapModeEx(GET_WRAP_MODE());
int edgeColumns[SMALL_BUFFER];
size_t const cnt = ReadVectorFromString(lpfv->wchMultiEdgeLines, edgeColumns, COUNTOF(edgeColumns), 0, LONG_LINES_MARKER_LIMIT, 0, true);

View File

@ -1901,7 +1901,32 @@ HWND InitInstance(const HINSTANCE hInstance, int nCmdShow)
break;
}
// Initial FileLoad() moved in front of ShowWindow()
// initial set text in front of ShowWindow()
EditSetNewText(Globals.hwndEdit, "", 0, false, false);
ShowWindowAsync(s_hwndEditFrame, SW_SHOWDEFAULT);
ShowWindowAsync(Globals.hwndEdit, SW_SHOWDEFAULT);
//~SnapToWinInfoPos(hwndMain, g_IniWinInfo, SCR_NORMAL, SW_HIDE); ~ instead set all needed properties here:
SetWindowPos(hwndMain, Settings.AlwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
if (!s_flagStartAsTrayIcon) {
UpdateWindow(hwndMain);
if (!Settings.ShowTitlebar) {
SetWindowLong(hwndMain, GWL_STYLE, GetWindowLong(hwndMain, GWL_STYLE) & ~WS_CAPTION);
}
}
else {
if (Settings.MinimizeToTray) {
MinimizeWndToTray(hwndMain);
}
else {
nCmdShow = SW_MINIMIZE;
}
ShowNotifyIcon(hwndMain, true);
SetNotifyIconTitle(hwndMain);
}
ShowWindow(hwndMain, nCmdShow);
bool bOpened = false;
// Pathname parameter
@ -1972,30 +1997,6 @@ HWND InitInstance(const HINSTANCE hInstance, int nCmdShow)
FileLoad(hfile_pth, fLoadFlags); // init editor frame
}
// now, after FileLoad() do ShowWindow()
ShowWindowAsync(s_hwndEditFrame, SW_SHOWDEFAULT);
ShowWindowAsync(Globals.hwndEdit, SW_SHOWDEFAULT);
//~SnapToWinInfoPos(hwndMain, g_IniWinInfo, SCR_NORMAL, SW_HIDE); ~ instead set all needed properties here:
SetWindowPos(hwndMain, Settings.AlwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
if (!s_flagStartAsTrayIcon) {
UpdateWindow(hwndMain);
if (!Settings.ShowTitlebar) {
SetWindowLong(hwndMain, GWL_STYLE, GetWindowLong(hwndMain, GWL_STYLE) & ~WS_CAPTION);
}
}
else {
if (Settings.MinimizeToTray) {
MinimizeWndToTray(hwndMain);
}
else {
nCmdShow = SW_MINIMIZE;
}
ShowNotifyIcon(hwndMain, true);
SetNotifyIconTitle(hwndMain);
}
ShowWindow(hwndMain, nCmdShow);
// reset
Encoding_Forced(CPI_NONE);
s_flagQuietCreate = false;
@ -2389,9 +2390,7 @@ static void _SetWrapIndentMode()
{
BeginWaitCursorUID(Flags.bHugeFileLoadState, IDS_MUI_SB_WRAP_LINES);
int const wrap_mode = (!Globals.fvCurFile.bWordWrap ? SC_WRAP_NONE : ((Settings.WordWrapMode == 0) ? SC_WRAP_WHITESPACE : SC_WRAP_CHAR));
SciCall_SetWrapMode(wrap_mode);
Sci_SetWrapModeEx(GET_WRAP_MODE());
if (Settings.WordWrapIndent == 5) {
SciCall_SetWrapIndentMode(SC_WRAPINDENT_SAME);

View File

@ -984,6 +984,14 @@ inline int Sci_GetCurrentEOL_W(LPWCH eol)
}
}
// ----------------------------------------------------------------------------
inline void Sci_SetWrapModeEx(const int wrapmode) {
if (wrapmode != SciCall_GetWrapMode()) {
SciCall_SetWrapMode(wrapmode);
}
}
// ----------------------------------------------------------------------------
inline DocPos Sci_GetSelectionStartEx()
{

View File

@ -1744,6 +1744,8 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew)
SciCall_SetLayoutCache(SC_CACHE_PAGE); //~SC_CACHE_DOCUMENT ~ memory consumption !
SciCall_SetPositionCache(SciCall_GetPositionCache()); // clear - default=1024
Sci_SetWrapModeEx(GET_WRAP_MODE());
SciCall_StartStyling(0);
//~SciCall_Colourise(0, -1);

View File

@ -963,6 +963,11 @@ typedef struct THEMEFILES {
#define NP3_VIRTUAL_SPACE_ACCESS_OPTIONS (Settings2.DenyVirtualSpaceAccess ? SCVS_NONE : SCVS_RECTANGULARSELECTION)
//=============================================================================
#define GET_WRAP_MODE() (!Globals.fvCurFile.bWordWrap ? SC_WRAP_NONE : ((Settings.WordWrapMode == 0) ? SC_WRAP_WHITESPACE : SC_WRAP_CHAR))
// The possible notification types are the same as the modificationType bit flags used by SCN_MODIFIED:
// SC_MOD_INSERTTEXT, SC_MOD_DELETETEXT, SC_MOD_CHANGESTYLE, SC_MOD_CHANGEFOLD, SC_PERFORMED_USER,
// SC_PERFORMED_UNDO, SC_PERFORMED_REDO, SC_MULTISTEPUNDOREDO, SC_LASTSTEPINUNDOREDO, SC_MOD_CHANGEMARKER,