Skip to content

Commit

Permalink
Added fast move and text exit without saving
Browse files Browse the repository at this point in the history
  • Loading branch information
CompSciOrBust committed Jan 22, 2020
1 parent 60d69d7 commit 9de3405
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 2 deletions.
74 changes: 72 additions & 2 deletions source/ExplorerUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,82 @@ void ExplorerUI::GetInput()
//Left pressed
else if(Event->jbutton.button == 12)
{
//Todo fast move
//If less items than there are spaces then move to the first item
if(FileNameList->ListingsOnScreen > FileNameList->ListingTextVec.size())
{
FileNameList->SelectedIndex = 0;
FileNameList->CursorIndex = 0;
}
//If the cursor is on the first item on the screen then move the cursor by the number of items on screen
else if(FileNameList->CursorIndex == 0)
{
//If we are on the first item jump to the last
if(FileNameList->SelectedIndex == 0)
{
FileNameList->SelectedIndex = FileNameList->ListingTextVec.size() -1;
FileNameList->CursorIndex = FileNameList->ListingsOnScreen -1;
FileNameList->ListRenderOffset = FileNameList->ListingTextVec.size() -1 - FileNameList->CursorIndex;
}
else
{
FileNameList->ListRenderOffset -= FileNameList->ListingsOnScreen;
FileNameList->SelectedIndex -= FileNameList->ListingsOnScreen;
FileNameList->CursorIndex = 0;
}
//Stop on the first item if we go past it
if(FileNameList->SelectedIndex < 0)
{
FileNameList->ListRenderOffset = 0;
FileNameList->SelectedIndex = 0;
FileNameList->CursorIndex = 0;
}
}
//If cursor isn't on the first item on screen then jump to it
else
{
FileNameList->SelectedIndex -= FileNameList->CursorIndex;
FileNameList->CursorIndex = 0;
}
}
//Right pressed
else if(Event->jbutton.button == 14)
{
//Todo fast move
//If less items than there are spaces then move to the last item
if(FileNameList->ListingsOnScreen > FileNameList->ListingTextVec.size())
{
FileNameList->SelectedIndex = FileNameList->ListingTextVec.size()-1;
FileNameList->CursorIndex = FileNameList->ListingTextVec.size()-1;
}
//If the cursor is on the last item on the screen then move the cursor by the number of items on screen
else if(FileNameList->CursorIndex == FileNameList->ListingsOnScreen -1)
{
//If we're on the last item jump to the first
if(FileNameList->SelectedIndex == FileNameList->ListingTextVec.size()-1)
{
FileNameList->ListRenderOffset = 0;
FileNameList->SelectedIndex = 0;
FileNameList->CursorIndex = 0;
}
else
{
FileNameList->ListRenderOffset += FileNameList->ListingsOnScreen - 1;
FileNameList->SelectedIndex += FileNameList->ListingsOnScreen;
FileNameList->CursorIndex = FileNameList->ListingsOnScreen;
}
//If we go past the last item jump back to it
if(FileNameList->SelectedIndex > FileNameList->ListingTextVec.size())
{
FileNameList->SelectedIndex = FileNameList->ListingTextVec.size() -1;
FileNameList->CursorIndex = FileNameList->ListingsOnScreen;
FileNameList->ListRenderOffset = FileNameList->ListingTextVec.size() -1 - FileNameList->CursorIndex;
}
}
//If cursor isn't on the last item on screen then jump to it
else
{
FileNameList->SelectedIndex += FileNameList->ListingsOnScreen - FileNameList->CursorIndex -1;
FileNameList->CursorIndex = FileNameList->ListingsOnScreen -1;
}
}
//A pressed
else if(Event->jbutton.button == 0)
Expand Down
5 changes: 5 additions & 0 deletions source/TextUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ void TextUI::GetInput()
string EditedLine = GetKeyboardInput("Done", "Edit line", LinesVec.at(SelectedLine));
LinesVec.at(SelectedLine) = EditedLine;
}
//Minus pressed (temp code until save as option is added)
else if(Event->jbutton.button == 11)
{
*WindowState = 0;
}
}
}
}
Expand Down

0 comments on commit 9de3405

Please sign in to comment.