From efb0c07ca2a6191037a6ca03b8d1dc75b5c0ff73 Mon Sep 17 00:00:00 2001 From: Peter Kwan Date: Sat, 15 Jun 2019 15:27:07 +0100 Subject: [PATCH] TAB for insert space Added the TAB key to insert a space at the cursor location, as edit.tf does. The remainder of the line to the right is shifted one character to the right. --- ttxpage.cpp | 21 +++++++++++++++------ wxTED.depend | 6 +++--- wxTEDMain.h | 4 ++-- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/ttxpage.cpp b/ttxpage.cpp index 88a79fa..ae19bb6 100644 --- a/ttxpage.cpp +++ b/ttxpage.cpp @@ -958,12 +958,6 @@ void TTXPage::SetCharAt(int code, int modifiers, wxPoint& cursorLoc, wxPoint& cu 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) { @@ -1204,6 +1198,21 @@ void TTXPage::SetCharAt(int code, int modifiers, wxPoint& cursorLoc, wxPoint& cu oldChar=line->SetCharAt(cursorLoc.x,'\r'); // Insert a double height if (cursorLoc.x<39) cursorLoc.x++; // Move right if possible AddEvent(EventKey,cursorLoc,oldChar,'\r'); + case WXK_TAB : // Insert space + { + auto loc=cursorLoc; + for (loc.x=39;loc.x>cursorLoc.x;loc.x--) + { + char oldch=line->GetCharAt(loc.x); + char newch=line->GetCharAt(loc.x-1); + AddEvent(EventKey, loc, oldch, newch); + line->SetCharAt(loc.x,newch); + } + // Last character is stuffed with a space + AddEvent(EventKey, loc, line->GetCharAt(cursorLoc.x), ' '); + line->SetCharAt(cursorLoc.x, ' '); // The current location is now a space + } + break; default: std::cout << "This key code is not implemented: " << code << std::endl; } diff --git a/wxTED.depend b/wxTED.depend index 78e3f0c..45a9879 100644 --- a/wxTED.depend +++ b/wxTED.depend @@ -2282,7 +2282,7 @@ 1560039184 source:e:\dev\wxted-github\wxted\ttxline.cpp "ttxline.h" -1560556379 source:e:\dev\wxted-github\wxted\ttxpage.cpp +1560611710 source:e:\dev\wxted-github\wxted\ttxpage.cpp "ttxpage.h" 1476983748 source:e:\dev\wxted-github\wxted\wxtedapp.cpp @@ -2382,7 +2382,7 @@ 1412634843 e:\dev\downloads\wxwidgets302\include\wx\univ\theme.h "wx/string.h" -1560374850 e:\dev\wxted-github\wxted\wxtedmain.h +1560612284 e:\dev\wxted-github\wxted\wxtedmain.h @@ -2794,7 +2794,7 @@ "wx/dynarray.h" "wx/vidmode.h" -1560382316 source:e:\dev\wxted-github\wxted\wxtedmain.cpp +1560556477 source:e:\dev\wxted-github\wxted\wxtedmain.cpp "wxTEDMain.h" "wx/wx.h" diff --git a/wxTEDMain.h b/wxTEDMain.h index cdee822..b81f56b 100644 --- a/wxTEDMain.h +++ b/wxTEDMain.h @@ -3,7 +3,7 @@ * Purpose: Defines Application Frame * Author: Peter Kwan (peterk.vt80@gmail.com) * Created: 2014-10-30 - * Copyright: Peter Kwan (http://www.teastop.co.uk) 2014-2018 + * Copyright: Peter Kwan (c) 2014-2019 * License: * * Permission to use, copy, modify, and distribute this software @@ -54,7 +54,7 @@ #include "mapchar.h" // Version number -#define VERSION_STRING wxT("1.37") +#define VERSION_STRING wxT("1.38") // ftp #include