Skip to content

Commit

Permalink
1. с форума: ShiftEnd и ShiftHome в панелях тормозят.
Browse files Browse the repository at this point in the history
  • Loading branch information
zg0 committed Jun 15, 2016
1 parent 8d42513 commit 53f2b8f
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 42 deletions.
4 changes: 4 additions & 0 deletions far/changelog
@@ -1,3 +1,7 @@
zg 15.06.2016 22:27:05 +0200 - build 4708

1. с форума: ShiftEnd и ShiftHome в панелях тормозят.

drkns 14.06.2016 18:31:09 +0200 - build 4707

1. Системные ассоциации, у которых "associated program" - bat или cmd, запускались в отдельном окне.
Expand Down
92 changes: 51 additions & 41 deletions far/filelist.cpp
Expand Up @@ -459,13 +459,18 @@ void FileList::ToEnd()
void FileList::MoveCursor(int offset)
{
m_CurFile = std::min(std::max(0, m_CurFile + offset), static_cast<int>(m_ListData.size() - 1));
}

void FileList::MoveCursorAndShow(int offset)
{
MoveCursor(offset);
ShowFileList(TRUE);
}

void FileList::Scroll(int offset)
{
m_CurTopFile += offset;
MoveCursor(offset);
MoveCursorAndShow(offset);
}

void FileList::CorrectPosition()
Expand Down Expand Up @@ -2268,20 +2273,20 @@ int FileList::ProcessKey(const Manager::Key& Key)
ToEnd();
return TRUE;
case KEY_UP: case KEY_NUMPAD8:
MoveCursor(-1);
MoveCursorAndShow(-1);
return TRUE;
case KEY_DOWN: case KEY_NUMPAD2:
MoveCursor(1);
MoveCursorAndShow(1);
return TRUE;
case KEY_PGUP: case KEY_NUMPAD9:
N=m_Columns*m_Height-1;
m_CurTopFile-=N;
MoveCursor(-N);
MoveCursorAndShow(-N);
return TRUE;
case KEY_PGDN: case KEY_NUMPAD3:
N=m_Columns*m_Height-1;
m_CurTopFile+=N;
MoveCursor(N);
MoveCursorAndShow(N);
return TRUE;
case KEY_LEFT: case KEY_NUMPAD4:

Expand All @@ -2290,7 +2295,7 @@ int FileList::ProcessKey(const Manager::Key& Key)
if (m_CurTopFile>=m_Height && m_CurFile-m_CurTopFile<m_Height)
m_CurTopFile-=m_Height;

MoveCursor(-m_Height);
MoveCursorAndShow(-m_Height);
return TRUE;
}

Expand All @@ -2302,7 +2307,7 @@ int FileList::ProcessKey(const Manager::Key& Key)
if (m_CurFile+m_Height < static_cast<int>(m_ListData.size()) && m_CurFile-m_CurTopFile>=(m_Columns-1)*(m_Height))
m_CurTopFile+=m_Height;

MoveCursor(m_Height);
MoveCursorAndShow(m_Height);
return TRUE;
}

Expand All @@ -2315,8 +2320,8 @@ int FileList::ProcessKey(const Manager::Key& Key)
{
InternalProcessKey++;
while (m_CurFile>0)
ProcessKey(Manager::Key(KEY_SHIFTUP));
ProcessKey(Manager::Key(KEY_SHIFTUP));
MoveSelection(up);
MoveSelection(up);
InternalProcessKey--;

if (SelectedFirst)
Expand All @@ -2329,9 +2334,9 @@ int FileList::ProcessKey(const Manager::Key& Key)
{
InternalProcessKey++;
while (m_CurFile < static_cast<int>(m_ListData.size() - 1))
ProcessKey(Manager::Key(KEY_SHIFTDOWN));
MoveSelection(down);

ProcessKey(Manager::Key(KEY_SHIFTDOWN));
MoveSelection(down);
InternalProcessKey--;

if (SelectedFirst)
Expand All @@ -2347,7 +2352,7 @@ int FileList::ProcessKey(const Manager::Key& Key)
InternalProcessKey++;

while (N--)
ProcessKey(Manager::Key(LocalKey==KEY_SHIFTPGUP||LocalKey==KEY_SHIFTNUMPAD9? KEY_SHIFTUP:KEY_SHIFTDOWN));
MoveSelection(LocalKey == KEY_SHIFTPGUP || LocalKey == KEY_SHIFTNUMPAD9 ? up : down);

InternalProcessKey--;

Expand All @@ -2369,7 +2374,7 @@ int FileList::ProcessKey(const Manager::Key& Key)
InternalProcessKey++;

while (N--)
ProcessKey(Manager::Key(LocalKey==KEY_SHIFTLEFT || LocalKey==KEY_SHIFTNUMPAD4? KEY_SHIFTUP:KEY_SHIFTDOWN));
MoveSelection(LocalKey == KEY_SHIFTLEFT || LocalKey == KEY_SHIFTNUMPAD4 ? up : down);

assert(m_CurFile < static_cast<int>(m_ListData.size()));
Select(m_ListData[m_CurFile], ShiftSelection);
Expand All @@ -2391,30 +2396,7 @@ int FileList::ProcessKey(const Manager::Key& Key)
case KEY_SHIFTUP: case KEY_SHIFTNUMPAD8:
case KEY_SHIFTDOWN: case KEY_SHIFTNUMPAD2:
{
if (m_ListData.empty())
return TRUE;

assert(m_CurFile < static_cast<int>(m_ListData.size()));
CurPtr = &m_ListData[m_CurFile];

if (ShiftSelection==-1)
{
// .. is never selected
if (m_CurFile < static_cast<int>(m_ListData.size() - 1) && TestParentFolderName(CurPtr->strName))
ShiftSelection = !m_ListData[m_CurFile+1].Selected;
else
ShiftSelection=!CurPtr->Selected;
}

Select(*CurPtr, ShiftSelection);

if (LocalKey==KEY_SHIFTUP || LocalKey == KEY_SHIFTNUMPAD8)
MoveCursor(-1);
else
MoveCursor(1);

if (SelectedFirst && !InternalProcessKey)
SortFileList(TRUE);
MoveSelection(LocalKey == KEY_SHIFTUP || LocalKey == KEY_SHIFTNUMPAD8 ? up : down);

ShowFileList(TRUE);
return TRUE;
Expand All @@ -2428,7 +2410,7 @@ int FileList::ProcessKey(const Manager::Key& Key)
CurPtr = &m_ListData[m_CurFile];
Select(*CurPtr,!CurPtr->Selected);
bool avoid_up_jump = SelectedFirst && (m_CurFile > 0) && (m_CurFile+1 == static_cast<int>(m_ListData.size())) && CurPtr->Selected;
MoveCursor(1);
MoveCursorAndShow(1);

if (SelectedFirst)
{
Expand Down Expand Up @@ -2690,7 +2672,7 @@ void FileList::ProcessEnter(bool EnableExec,bool SeparateWindow,bool EnableAssoc
QuoteSpace(Info.Command);

Parent()->GetCmdLine()->ExecString(Info);

const auto ExclusionFlag = IsItExecutable? EXCLUDECMDHISTORY_NOTPANEL : EXCLUDECMDHISTORY_NOTWINASS;
if (!(Global->Opt->ExcludeCmdHistory & ExclusionFlag) && !PluginMode)
Global->CtrlObject->CmdHistory->AddToHistory(strFileName, HR_DEFAULT, nullptr, nullptr, m_CurDir.data());
Expand Down Expand Up @@ -3137,7 +3119,7 @@ int FileList::ProcessMouse(const MOUSE_EVENT_RECORD *MouseEvent)

while (IsMouseButtonPressed() && IntKeyState.MouseY<=m_Y1+1)
{
MoveCursor(-1);
MoveCursorAndShow(-1);

if (IntKeyState.MouseButtonState==RIGHTMOST_BUTTON_PRESSED)
{
Expand All @@ -3161,7 +3143,7 @@ int FileList::ProcessMouse(const MOUSE_EVENT_RECORD *MouseEvent)

while (IsMouseButtonPressed() && IntKeyState.MouseY>=m_Y2-2)
{
MoveCursor(1);
MoveCursorAndShow(1);

if (IntKeyState.MouseButtonState==RIGHTMOST_BUTTON_PRESSED)
{
Expand Down Expand Up @@ -8753,3 +8735,31 @@ content_data_ptr FileList::GetContentData(const string& Item) const
}
return Result;
}

void FileList::MoveSelection(direction Direction)
{
if (m_ListData.empty())
return;

assert(m_CurFile < static_cast<int>(m_ListData.size()));
auto CurPtr = &m_ListData[m_CurFile];

if (ShiftSelection==-1)
{
// .. is never selected
if (m_CurFile < static_cast<int>(m_ListData.size() - 1) && TestParentFolderName(CurPtr->strName))
ShiftSelection = !m_ListData[m_CurFile+1].Selected;
else
ShiftSelection=!CurPtr->Selected;
}

Select(*CurPtr, ShiftSelection);

if (Direction == up)
MoveCursor(-1);
else
MoveCursor(1);

if (SelectedFirst && !InternalProcessKey)
SortFileList(TRUE);
}
4 changes: 4 additions & 0 deletions far/filelist.hpp
Expand Up @@ -280,6 +280,7 @@ class FileList:public Panel
void ToBegin();
void ToEnd();
void MoveCursor(int offset);
void MoveCursorAndShow(int offset);
void Scroll(int offset);
void CorrectPosition();
void ShowFileList(int Fast);
Expand Down Expand Up @@ -327,6 +328,9 @@ class FileList:public Panel
void InitFSWatcher(bool CheckTree);
bool IsColumnDisplayed(std::function<bool(const column&)> Compare) const;
void UpdateHeight();
enum direction { up, down };
void MoveSelection(direction Direction);


static void DeletePluginItemList(std::vector<PluginPanelItem> &ItemList);
static void FillParentPoint(FileListItem& Item, size_t CurFilePos, const FILETIME* Times = nullptr);
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
@@ -1 +1 @@
m4_define(BUILD,4707)m4_dnl
m4_define(BUILD,4708)m4_dnl

0 comments on commit 53f2b8f

Please sign in to comment.