Skip to content

Commit

Permalink
Delete key
Browse files Browse the repository at this point in the history
Delete key implemented. Next to implement is TAB key for inserting a space.
  • Loading branch information
peterkvt80 committed Jun 14, 2019
1 parent 0b29241 commit bb1ff5f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
24 changes: 23 additions & 1 deletion ttxpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ void TTXPage::SetCharAt(int code, int modifiers, wxPoint& cursorLoc, wxPoint& cu
// Also want to delete!

case WXK_DELETE:
// Delete the whole row
// Delete the whole row. Don't think this gets used!
for (cursorLoc.x=0;cursorLoc.x<40;cursorLoc.x++)
{
AddEvent(EventKey,cursorLoc,line->GetCharAt(cursorLoc.x),' ');
Expand All @@ -895,6 +895,7 @@ void TTXPage::SetCharAt(int code, int modifiers, wxPoint& cursorLoc, wxPoint& cu
line->ClearLine();
std::cout << "TODO: [1] Implement AddChange " << std::endl;
ch=0;
code=0;
break;
// Would like to implement CTRL-ENTER, but no dice ;-(

Expand Down Expand Up @@ -942,6 +943,27 @@ void TTXPage::SetCharAt(int code, int modifiers, wxPoint& cursorLoc, wxPoint& cu
{
switch (code)
{
case WXK_DELETE : // all characters to the right shift one to the left
{
auto loc=cursorLoc;
for (;loc.x<39;loc.x++)
{
char ch=line->GetCharAt(loc.x+1);
AddEvent(EventKey,loc,line->GetCharAt(loc.x),ch);
line->SetCharAt(loc.x,ch);
}
// Last character is stuffed with a space
char ch=line->GetCharAt(39);
AddEvent(EventKey,loc,ch,' ');
line->SetCharAt(39,' ');
}
break;
case WXK_TAB : // Insert a space at the current location and shift right everything on the right
// Shift everything to the right, one space.@todo
// Insert a space
std::cout << "PRESSED TAB" << std::endl;
line->SetCharAt(cursorLoc.x,' ?'); //
break;
case WXK_HOME : // Move to start of line
if (cursorLoc.x>0)
{
Expand Down
4 changes: 2 additions & 2 deletions wxTED.depend
Original file line number Diff line number Diff line change
Expand Up @@ -2282,7 +2282,7 @@
1560039184 source:e:\dev\wxted-github\wxted\ttxline.cpp
"ttxline.h"

1560374868 source:e:\dev\wxted-github\wxted\ttxpage.cpp
1560556379 source:e:\dev\wxted-github\wxted\ttxpage.cpp
"ttxpage.h"

1476983748 source:e:\dev\wxted-github\wxted\wxtedapp.cpp
Expand Down Expand Up @@ -2794,7 +2794,7 @@
"wx/dynarray.h"
"wx/vidmode.h"

1560036925 source:e:\dev\wxted-github\wxted\wxtedmain.cpp
1560382316 source:e:\dev\wxted-github\wxted\wxtedmain.cpp
"wxTEDMain.h"
<wx/msgdlg.h>
"wx/wx.h"
Expand Down
7 changes: 4 additions & 3 deletions wxTEDMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,10 @@ void wxTEDFrame::OnChar(wxKeyEvent& event)
break;
case WXK_CONTROL:
break;
case WXK_TAB: // This will insert a space
std::cout << "Insert a space TBA" << std::endl;
break;
// Moved this to ttxpage as it acts on the page
//case WXK_TAB: // This will insert a space
// std::cout << "Insert a space TBA" << std::endl;
//break;
default:
// If the last key pressed was escape, we are doing an edit.tf style escape
if (m_escapeMode)
Expand Down

0 comments on commit bb1ff5f

Please sign in to comment.