Skip to content

Commit

Permalink
edit.tf keys
Browse files Browse the repository at this point in the history
Implemented many edit.tf teletext commands. Not implemented: block commands and metacommands like redraw screem
  • Loading branch information
peterkvt80 committed Jun 12, 2019
1 parent 938e023 commit 0b29241
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 107 deletions.
34 changes: 1 addition & 33 deletions ttxpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,7 @@ TTXPage::TTXPage(std::string filename, std::string shortFilename) :
m_SubPage(nullptr),
undoList(nullptr),
m_current(nullptr),
m_loaded(false),
m_escapeMode(false)
m_loaded(false)
{
//std::cout << "[TTXPage] file constructor" << std::endl;
m_Init();
Expand Down Expand Up @@ -811,33 +810,6 @@ void TTXPage::SetCharAt(int code, int modifiers, wxPoint& cursorLoc, wxPoint& cu
// Do not allow DoubleHeight on row 23 or 24
if (cursorLoc.y>22 && code==WXK_CONTROL_M) return;

// If the last key pressed was escape, we are doing an edit.tf style escape
if (m_escapeMode)
{
m_escapeMode=false;
// Find the key that was pressed, and map it to a native keycode
switch (code)
{
case 'r': modifiers=wxMOD_SHIFT; code=WXK_F1;break; // alpha red
case 'R': modifiers=wxMOD_CONTROL; code=WXK_F1;break; // mosaic red
case 'g': modifiers=wxMOD_SHIFT; code=WXK_F2;break; // alpha green
case 'G': modifiers=wxMOD_CONTROL; code=WXK_F2;break; // mosaic green
case 'y': modifiers=wxMOD_SHIFT; code=WXK_F3;break; // alpha yellow
case 'Y': modifiers=wxMOD_CONTROL; code=WXK_F3;break; // mosaic yellow
case 'b': modifiers=wxMOD_SHIFT; code=WXK_F4;break; // alpha blue
case 'B': modifiers=wxMOD_CONTROL; code=WXK_F4;break; // mosaic blue
case 'm': modifiers=wxMOD_SHIFT; code=WXK_F5;break; // alpha magenta
case 'M': modifiers=wxMOD_CONTROL; code=WXK_F5;break; // mosaic magenta
case 'c': modifiers=wxMOD_SHIFT; code=WXK_F6;break; // alpha cyan
case 'C': modifiers=wxMOD_CONTROL; code=WXK_F6;break; // mosaic cyan
case 'w': modifiers=wxMOD_SHIFT; code=WXK_F7;break; // alpha white
case 'W': modifiers=wxMOD_CONTROL; code=WXK_F7;break; // mosaic white
case 'k': modifiers=wxMOD_SHIFT; code=WXK_F8;break; // alpha black
case 'K': modifiers=wxMOD_CONTROL; code=WXK_F8;break; // mosaic black
// @todo Lots more codes
}
} // edit.tf escape mode

TTXLine* line=m_pLine[cursorLoc.y];

// Is the line NULL? If so we had better make the line!
Expand Down Expand Up @@ -1210,10 +1182,6 @@ 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_ESCAPE : // Escape - Start edit.tf code
// @todo Work out how Undo will work.
m_escapeMode=true; // Record that this we are in escape mode.
break;
default:
std::cout << "This key code is not implemented: " << code << std::endl;
}
Expand Down
1 change: 0 additions & 1 deletion ttxpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ class TTXPage
int findPageNumber(char* buf);

bool m_loaded;
bool m_escapeMode; /// True if the last key pressed was Escape

};

Expand Down
42 changes: 21 additions & 21 deletions wxTED.cscope_file_list
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
"E:\dev\wxTED-GitHub\wxted\wxTEDApp.cpp"
"E:\dev\wxTED-GitHub\wxted\ttxline.h"
"E:\dev\wxTED-GitHub\wxted\teletext40.h"
"E:\dev\wxTED-GitHub\wxted\charchange.cpp"
"E:\dev\wxTED-GitHub\wxted\wxsmith\PublishSetupDialog.wxs"
"E:\dev\wxTED-GitHub\wxted\wxsmith\wxTEDframe.wxs"
"E:\dev\wxTED-GitHub\wxted\teddybear.ico"
"E:\dev\wxTED-GitHub\wxted\resource.rc"
"E:\dev\wxTED-GitHub\wxted\wxTEDMain.cpp"
"E:\dev\wxTED-GitHub\wxted\wxTEDMain.h"
"E:\dev\wxTED-GitHub\wxted\HelpFrame.cpp"
"E:\dev\wxTED-GitHub\wxted\wxTEDApp.h"
"E:\dev\wxTED-GitHub\wxted\HelpFrame.h"
"E:\dev\wxTED-GitHub\wxted\tedevent.cpp"
"E:\dev\wxTED-GitHub\wxted\PublishSetupDialog.cpp"
"E:\dev\wxTED-GitHub\wxted\mapchar.h"
"E:\dev\wxTED-GitHub\wxted\ttxpage.h"
"E:\dev\wxTED-GitHub\wxted\PageSettingsDialog.cpp"
"E:\dev\wxTED-GitHub\wxted\tedevent.h"
"E:\dev\wxTED-GitHub\wxted\PageSettingsDialog.h"
"E:\dev\wxTED-GitHub\wxted\PublishSetupDialog.cpp"
"E:\dev\wxTED-GitHub\wxted\wxTEDMain.h"
"E:\dev\wxTED-GitHub\wxted\teletext40.cpp"
"E:\dev\wxTED-GitHub\wxted\wxsmith\HelpFrame1.wxs"
"E:\dev\wxTED-GitHub\wxted\teletext40.h"
"E:\dev\wxTED-GitHub\wxted\HelpFrame.cpp"
"E:\dev\wxTED-GitHub\wxted\ttxcodes.h"
"E:\dev\wxTED-GitHub\wxted\ttxline.cpp"
"E:\dev\wxTED-GitHub\wxted\wxTEDApp.h"
"E:\dev\wxTED-GitHub\wxted\ttxline.h"
"E:\dev\wxTED-GitHub\wxted\wxsmith\PageSettingsDialog.wxs"
"E:\dev\wxTED-GitHub\wxted\PublishSetupDialog.h"
"E:\dev\wxTED-GitHub\wxted\ttxpage.cpp"
"E:\dev\wxTED-GitHub\wxted\charchange.h"
"E:\dev\wxTED-GitHub\wxted\ttxline.cpp"
"E:\dev\wxTED-GitHub\wxted\mapchar.h"
"E:\dev\wxTED-GitHub\wxted\wxsmith\PublishSetupDialog.wxs"
"E:\dev\wxTED-GitHub\wxted\PageSettingsDialog.cpp"
"E:\dev\wxTED-GitHub\wxted\charchange.cpp"
"E:\dev\wxTED-GitHub\wxted\ttxpage.h"
"E:\dev\wxTED-GitHub\wxted\wxTEDApp.cpp"
"E:\dev\wxTED-GitHub\wxted\mapchar.cpp"
"E:\dev\wxTED-GitHub\wxted\wxsmith\PageSettingsDialog.wxs"
"E:\dev\wxTED-GitHub\wxted\resource.rc"
"E:\dev\wxTED-GitHub\wxted\tedevent.cpp"
"E:\dev\wxTED-GitHub\wxted\teddybear.ico"
"E:\dev\wxTED-GitHub\wxted\wxsmith\wxTEDframe.wxs"
"E:\dev\wxTED-GitHub\wxted\wxsmith\HelpFrame1.wxs"
"E:\dev\wxTED-GitHub\wxted\teletext40.cpp"
"E:\dev\wxTED-GitHub\wxted\HelpFrame.h"
6 changes: 3 additions & 3 deletions wxTED.depend
Original file line number Diff line number Diff line change
Expand Up @@ -2254,7 +2254,7 @@
"string.h"
"ttxpage.h"

1560294115 e:\dev\wxted-github\wxted\ttxpage.h
1560374850 e:\dev\wxted-github\wxted\ttxpage.h
<stdlib.h>
"string.h"
<iostream>
Expand Down Expand Up @@ -2282,7 +2282,7 @@
1560039184 source:e:\dev\wxted-github\wxted\ttxline.cpp
"ttxline.h"

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

1476983748 source:e:\dev\wxted-github\wxted\wxtedapp.cpp
Expand Down Expand Up @@ -2382,7 +2382,7 @@
1412634843 e:\dev\downloads\wxwidgets302\include\wx\univ\theme.h
"wx/string.h"

1560039461 e:\dev\wxted-github\wxted\wxtedmain.h
1560374850 e:\dev\wxted-github\wxted\wxtedmain.h
<wx/notebook.h>
<wx/menu.h>
<wx/panel.h>
Expand Down
160 changes: 111 additions & 49 deletions wxTEDMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,56 +145,110 @@ void wxTEDFrame::OnSize(wxSizeEvent& event)

void wxTEDFrame::OnChar(wxKeyEvent& event)
{
int code=event.GetKeyCode();
int modifiers=event.GetModifiers();
// std::cout << "Key event..." << code << std::endl;
// We look at a few codes which apply to a page set rather than just a single page
TEDEvent* tev;
switch (code)
int code=event.GetKeyCode();
int modifiers=event.GetModifiers();
// std::cout << "Key event..." << code << std::endl;
// We look at a few codes which apply to a page set rather than just a single page
// If none of these codes apply, we send the character to the page
TEDEvent* tev;
// Toggle invisible control codes?
if (m_escapeMode)
{
if (code=='Q' || code=='X') // Codes and Grid are combined in wxTED
{
case WXK_PAGEUP:
// std::cout << "Page up will get next page of a multiple page carousel" << std::endl;
if ( m_cursorPoint.y<1) // @todo Temporary hack to stop crash, when going up one page while on row 0.
m_cursorPoint.y=1;
iPageCount=m_rootPage->GetPageCount();
iPage++;
if (iPage>=iPageCount) iPage=iPageCount-1;
m_currentPage=m_rootPage->GetPage(iPage);
//std::cout << "iPage= " << iPage << std::endl;
break;
case WXK_PAGEDOWN:
// std::cout << "Page down will get previous page of a multiple page carousel" << std::endl;
iPageCount=m_rootPage->GetPageCount();
iPage--;
if (iPage<0) iPage=0;
m_currentPage=m_rootPage->GetPage(iPage);
//std::cout << "iPage= " << iPage << std::endl;
break;
case WXK_F11: // Reveal concealed text
m_reveal=!m_reveal;
break;
case WXK_CONTROL_Y: // Ah. This is why we can't use CTRL-Y as a special key. This was for debugging undo.
// std::cout << "CTRL-Y test" << std::endl; // Testing
tev=m_currentPage->GetUndo();
if (tev!=NULL)
tev->dump();
break;
case WXK_CONTROL_Z:
// std::cout << "CTRL-Z undo" << std::endl;
// tev=m_currentPage->GetUndo();
m_currentPage->Undo(m_cursorPoint);
break;
case WXK_CONTROL:
break;
default:
m_currentPage->SetCharAt(code, modifiers, m_cursorPoint, m_subPixelPoint, MenuItemShowHeader->IsChecked());
m_ShowMarkup=!m_ShowMarkup;
code=WXK_ESCAPE;
}
}
switch (code)
{
case WXK_ESCAPE:
m_escapeMode=!m_escapeMode;
break;
case WXK_PAGEUP:
// std::cout << "Page up will get next page of a multiple page carousel" << std::endl;
if ( m_cursorPoint.y<1) // @todo Temporary hack to stop crash, when going up one page while on row 0.
m_cursorPoint.y=1;
iPageCount=m_rootPage->GetPageCount();
iPage++;
if (iPage>=iPageCount) iPage=iPageCount-1;
m_currentPage=m_rootPage->GetPage(iPage);
//std::cout << "iPage= " << iPage << std::endl;
break;
case WXK_PAGEDOWN:
// std::cout << "Page down will get previous page of a multiple page carousel" << std::endl;
iPageCount=m_rootPage->GetPageCount();
iPage--;
if (iPage<0) iPage=0;
m_currentPage=m_rootPage->GetPage(iPage);
//std::cout << "iPage= " << iPage << std::endl;
break;
case WXK_F11: // Reveal concealed text
m_reveal=!m_reveal;
break;
case WXK_CONTROL_Y: // Ah. This is why we can't use CTRL-Y as a special key. This was for debugging undo.
// std::cout << "CTRL-Y test" << std::endl; // Testing
tev=m_currentPage->GetUndo();
if (tev!=NULL)
{
tev->dump();
}
break;
case WXK_CONTROL_Z:
// std::cout << "CTRL-Z undo" << std::endl;
// tev=m_currentPage->GetUndo();
m_currentPage->Undo(m_cursorPoint);
break;
case WXK_CONTROL:
break;
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)
{
m_escapeMode=false;
// Find the key that was pressed, and map it to a native keycode
switch (code)
{
case 'r': modifiers=wxMOD_SHIFT; code=WXK_F1;break; // alpha red
case 'R': modifiers=wxMOD_CONTROL; code=WXK_F1;break; // mosaic red
case 'g': modifiers=wxMOD_SHIFT; code=WXK_F2;break; // alpha green
case 'G': modifiers=wxMOD_CONTROL; code=WXK_F2;break; // mosaic green
case 'y': modifiers=wxMOD_SHIFT; code=WXK_F3;break; // alpha yellow
case 'Y': modifiers=wxMOD_CONTROL; code=WXK_F3;break; // mosaic yellow
case 'b': modifiers=wxMOD_SHIFT; code=WXK_F4;break; // alpha blue
case 'B': modifiers=wxMOD_CONTROL; code=WXK_F4;break; // mosaic blue
case 'm': modifiers=wxMOD_SHIFT; code=WXK_F5;break; // alpha magenta
case 'M': modifiers=wxMOD_CONTROL; code=WXK_F5;break; // mosaic magenta
case 'c': modifiers=wxMOD_SHIFT; code=WXK_F6;break; // alpha cyan
case 'C': modifiers=wxMOD_CONTROL; code=WXK_F6;break; // mosaic cyan
case 'w': modifiers=wxMOD_SHIFT; code=WXK_F7;break; // alpha white
case 'W': modifiers=wxMOD_CONTROL; code=WXK_F7;break; // mosaic white
case 'k': modifiers=wxMOD_SHIFT; code=WXK_F8;break; // alpha black
case 'K': modifiers=wxMOD_CONTROL; code=WXK_F8;break; // mosaic black
case 'N': modifiers=wxMOD_CONTROL; code=WXK_CONTROL_B; break; // new background
case 'n': modifiers=wxMOD_CONTROL; code=WXK_CONTROL_U; break; // black background
case 'f': modifiers=wxMOD_CONTROL; code=WXK_CONTROL_I; break; // steady
case 'F': modifiers=wxMOD_CONTROL; code=WXK_CONTROL_H; break; // flash
case 'h': modifiers=wxMOD_CONTROL; code=WXK_CONTROL_X; break; // release
case 'H': modifiers=wxMOD_CONTROL; code=WXK_CONTROL_W; break; // hold
case 'd': modifiers=wxMOD_CONTROL; code=WXK_CONTROL_L; break; // normal height
case 'D': modifiers=wxMOD_CONTROL; code=WXK_CONTROL_M; break; // double height
case 'O': modifiers=wxMOD_CONTROL; code=WXK_CONTROL_R; break; // conceal
case 'J': modifiers=wxMOD_NONE; code=172; break; // hook maps to text block
// @todo Lots more codes
}
} // edit.tf escape mode
m_currentPage->SetCharAt(code, modifiers, m_cursorPoint, m_subPixelPoint, MenuItemShowHeader->IsChecked());
}

//std::cout << "Cursor = " << m_cursorPoint.x << "." << m_subPixelPoint.x << ", "
// << m_cursorPoint.y << "." << m_subPixelPoint.y << ", " << std::endl;
m_cursorIsAlpha=m_currentPage->IsAlphaMode(m_cursorPoint);
m_blinkToggle=true; // HCI: Make cursor moves immediately visible
Refresh();
//std::cout << "Cursor = " << m_cursorPoint.x << "." << m_subPixelPoint.x << ", "
// << m_cursorPoint.y << "." << m_subPixelPoint.y << ", " << std::endl;
m_cursorIsAlpha=m_currentPage->IsAlphaMode(m_cursorPoint);
m_blinkToggle=true; // HCI: Make cursor moves immediately visible
Refresh();
}

void wxTEDFrame::OnTimer(wxTimerEvent& event)
Expand Down Expand Up @@ -1082,8 +1136,16 @@ void wxTEDFrame::m_SetStatus()
StatusBar1->SetLabelText(str.str());
}
wxTEDFrame::wxTEDFrame(wxWindow* parent,wxWindowID id, wxString initialPage)
: m_menuCount(0), m_inhibitStatus(false), m_ttxW(15), m_ttxH(20), m_subPixelPoint(wxPoint(0,0)), m_cursorIsAlpha(true)
, m_dragging(false), m_MarqueeStart(wxPoint(0,0)), m_currentPage(NULL)
: m_escapeMode(false)
, m_menuCount(0)
, m_inhibitStatus(false)
, m_ttxW(15)
, m_ttxH(20)
, m_subPixelPoint(wxPoint(0,0))
, m_cursorIsAlpha(true)
, m_dragging(false)
, m_MarqueeStart(wxPoint(0,0))
, m_currentPage(NULL)
{
// std::cout << "[wxTEDFrame] Entered" << std::endl;
m_parentWindow=parent;
Expand Down
1 change: 1 addition & 0 deletions wxTEDMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class wxTEDFrame: public wxFrame
inline TTXPage* Page(){return m_rootPage;};

private:
bool m_escapeMode; /// True if the last key pressed was Escape
int m_menuCount; // How many menus are open
bool m_inhibitStatus; // Inhibit the status bar while menus are up

Expand Down

0 comments on commit 0b29241

Please sign in to comment.