Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
Crash due to re-opening the Special Keys window fixed. Occasional crash due to typing on the end of a double height line fixed. Navigating across double height lines wasn't always correct.
  • Loading branch information
peterkvt80 committed Feb 8, 2020
1 parent 3be3ad0 commit d222394
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 71 deletions.
7 changes: 7 additions & 0 deletions HelpFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ HelpFrame::HelpFrame(wxWindow* parent,wxWindowID id,const wxPoint& pos,const wxS
Move(wxDefaultPosition);
HtmlWindow1 = new wxHtmlWindow(this, ID_HTMLWINDOW1, wxPoint(0,72), wxSize(344,384), wxHW_SCROLLBAR_AUTO, _T("ID_HTMLWINDOW1"));
HtmlWindow1->SetPage(_("<html>\n\n<style>\nbody {\n font-family: Helvetica, Arial, Sans-Serif;\n}\n\n</style>\n\n<body>\n<div style=\"border:2px black solid; display: inline-block;\">\n\t<span style=\"display: inline-block; background-color:#FFFFBB\">\n\t\t<b>Special keys</b><br/>\n\t\tPage Up - Show next page of carousel<br/>\n\t\tPage Down - Show previous page of carousel<br/>\n\t\tF11 - Hide/Reveal<br/>\n\t\tCTRL-Z - Undo<br/>\n\t\tAlt-Gr - Show control codes<br/>\n\t</span>\n</div>\n<div style=\"border:2px black solid; display: inline-block;\">\n\t<b>Text colours</b><br/>\n\t<span style=\"display: inline-block;\">\n\t\tShift-F1 - Red text<br/>\n\t\tShift-F2 - Green text<br/>\n\t\tShift-F3 - Yellow text<br/>\n\t\tShift-F4 - Blue text<br/>\n\t\tShift-F5 - Magenta text<br/>\n\t\tShift-F6 - Cyan text<br/>\n\t\tShift-F7 - White text<br/>\n\t\tShift-F8 - Black text (Level 2.5)<br/>\n\t</span>\n\t<b>Graphic colours</b>\tWhen the small graphics cursor is displayed then pressing space will toggle the pixel on and off. Also, the keys q,w,a,s,z,x toggle individual bits within a mosaic character<br/>\n\t<span style=\"display: inline-block; background-color:#BBBBBB\">\n\t\tCtrl-F1 - Graphics red<br/>\n\t\tCtrl-F2 - Graphics green<br/>\n\t\tCtrl-F3 - Graphics yellow<br/>\n\t\tCtrl-F4 - Graphics blue<br/>\n\t\tCtrl-F5 - Graphics magenta<br/>\n\t\tCtrl-F6 - Graphics cyan<br/>\n\t\tCtrl-F7 - Graphics white<br/>\n\t\tCtrl-F8 - Graphics black (Level 2.5)<br/>\n\t</span>\n</div>\n<div style=\"border:2px black solid; display: inline-block;\">\n\t<b>Effects</b><br/>\n\t<span style=\"display: inline-block; background-color:#BBBBBB\">\n\t\tCTRL-H - Flash<br/>\n\t\tCTRL-I - Steady<br/>\n\t\tCTRL-J - End Box<br/>\n\t\tCTRL-K - Start Box<br/>\n\t\tCTRL-L - Normal height<br/>\n\t\tCTRL-M (enter) - Double height<br/>\n\t\tCTRL-R - Conceal display<br/>\n\t\tCTRL-D - Contiguous graphics<br/>\n\t\tCTRL-T - Separated graphics<br/>\n\t\tCTRL-U - Black background<br/>\n\t\tCTRL-B - New background<br/>\n\t\tCTRL-W - Hold graphics<br/>\n\t\tCTRL-X - Release graphics<br/>\n <br/>\n CTRL-BACKSPACE - Delete Row<br/>\n\t</span>\n</div>\n\n</body>\n</html>"));

Connect(wxID_ANY,wxEVT_CLOSE_WINDOW,(wxObjectEventFunction)&HelpFrame::OnClose);
//*)
}

Expand All @@ -31,3 +33,8 @@ HelpFrame::~HelpFrame()
//*)
}


void HelpFrame::OnClose(wxCloseEvent& event)
{
Show(false);
}
1 change: 1 addition & 0 deletions HelpFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class HelpFrame: public wxFrame
private:

//(*Handlers(HelpFrame)
void OnClose(wxCloseEvent& event);
//*)

DECLARE_EVENT_TABLE()
Expand Down
4 changes: 2 additions & 2 deletions release.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ Build->Select Target

6) Run Inno Script Studio using the configuration that is in the Release folder and load winpackage.iss.
Set the myAppVersion and VersionInfoVersion to the new version number.
Select Project->Compile.
Select Build->Compile.
This creates a setup.exe in the same folder.
Rename setup.exe to include the version number like setup_1_14.exe.
Rename setup.exe to include the version number like setup_1.45.exe.


7) Open the Github repo online https://github.com/peterkvt80/wxted
Expand Down
23 changes: 23 additions & 0 deletions ttxline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,29 @@ std::string TTXLine::GetMappedline7bit()
return str;
}

bool TTXLine::HasDoubleHeight()
{
bool doubleHeight=false;
uint8_t x=40;
if (m_textline.empty())
{
return false;
}
// If the line we are testing isn't long enough, just check the last character.
if (m_textline.length()<x)
{
x=m_textline.length()-1;
}
for (unsigned int i=0;i<=x;i++)
{
if (m_textline[i]=='\r')
{
doubleHeight=true;
}
}
return doubleHeight;
} // HasDoubleHeight


bool TTXLine::IsDoubleHeight(int xLoc=39)
{
Expand Down
11 changes: 9 additions & 2 deletions ttxline.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,19 @@ class TTXLine
*/
std::string GetLine();

/** True if the line is double height
* @todo This is not good enough. Need to know the state at a particular point on a line. Add a character position parameter.
/** @brief Find if a particular character on a line is double height
* @param xLoc Location of the character we want to know if it is double height. (default 39)
* @return true if the character at xLoc is double height
*/
bool IsDoubleHeight(int xLoc);

/** @brief Find if the line contains double height
* This is needed because if a line contains any double height, the next line is skipped,
* even if the character location would be single height.
* @return true if any part of the line is double height
*/
bool HasDoubleHeight();

/**
* @brief Check if the line is blank so that we don't bother to write it to the file.
* @return true is the line is blank
Expand Down
20 changes: 12 additions & 8 deletions ttxpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@ TTXPage::~TTXPage()
{
static int j=0;
j++;
// std::cout << "[~TTXPage]" << std::endl;
for (int i=0;i<=MAXROW;i++)
{
// std::cout << "Deleting line " << i << std::endl;
if (m_pLine[i]!=nullptr)
{
delete m_pLine[i];
Expand Down Expand Up @@ -817,6 +815,7 @@ Other control codes TBA.
*/
void TTXPage::SetCharAt(int code, int modifiers, wxPoint& cursorLoc, wxPoint& cursorSubLoc, bool ShowHeader)
{

int yMin=1; // If we show the header, then enable row 0
if (ShowHeader)
{
Expand All @@ -835,6 +834,7 @@ void TTXPage::SetCharAt(int code, int modifiers, wxPoint& cursorLoc, wxPoint& cu
// Create a line if it is null
line=m_pLine[cursorLoc.y]=new TTXLine(" ");
}

// todo: Are there any more characters allowed in graphics mode? I think there are! CHECK!!!!

// Move cursor a whole space if Alpha mode, or @ to _ (0x40 to 0x5f) or a control code.
Expand Down Expand Up @@ -1054,7 +1054,7 @@ void TTXPage::SetCharAt(int code, int modifiers, wxPoint& cursorLoc, wxPoint& cu
// If we would move into the lower row of a double height, we need to decrement twice.
if (cursorLoc.y>2)
{
if (GetRow(cursorLoc.y-2)->IsDoubleHeight(cursorLoc.x))
if (GetRow(cursorLoc.y-2)->HasDoubleHeight())
{
cursorLoc.y--;
}
Expand Down Expand Up @@ -1090,8 +1090,8 @@ void TTXPage::SetCharAt(int code, int modifiers, wxPoint& cursorLoc, wxPoint& cu
{
if (cursorLoc.y<24)
{
// If the last location was the top of a double height, we need to increment twice.
if (GetRow(cursorLoc.y)->IsDoubleHeight(cursorLoc.x) && cursorLoc.y<23)
// If the last location was the top half of a double height, we need to increment twice.
if (GetRow(cursorLoc.y)->HasDoubleHeight() && cursorLoc.y<23)
{
cursorLoc.y++;
}
Expand Down Expand Up @@ -1148,7 +1148,7 @@ void TTXPage::SetCharAt(int code, int modifiers, wxPoint& cursorLoc, wxPoint& cu
}
break;
default :
// std::cout << "Default branch taken in SetCharAt " << (int)code << "i=" << instance << std::endl;
// std::cout << "Default branch taken in SetCharAt " << (int)code << " i=" << instance << std::endl;
if (line)
{
// By now we should only have teletext codes. If the new code is NOT a graphic then treat it as a character
Expand All @@ -1167,11 +1167,16 @@ void TTXPage::SetCharAt(int code, int modifiers, wxPoint& cursorLoc, wxPoint& cu
}
else
{
// If this is double height, we need to skip an extra line
if (cursorLoc.y<23 && line->HasDoubleHeight())
{
cursorLoc.y++;
}
if (cursorLoc.y<24)
{
cursorLoc.y++;
cursorLoc.x=0;
// If we have effects set up o n the left edge we would lose it
// If we have effects set up on the left edge we would lose it
// so we check the first three characters just in case
TTXLine* line2=m_pLine[cursorLoc.y];
// Allow for up to three control codes on a wrap
Expand Down Expand Up @@ -1233,7 +1238,6 @@ void TTXPage::SetCharAt(int code, int modifiers, wxPoint& cursorLoc, wxPoint& cu
// Deal with control codes that we might get sent
// Backspace, line feed, carriage return. A lot of stuff to trap
char oldChar;
std::cout << "[TTXPage::SetCharAt]TRACE 1" << std::endl;
switch (code)
{
case WXK_BACK : // backspace 8
Expand Down
12 changes: 6 additions & 6 deletions wxTED.depend
Original file line number Diff line number Diff line change
Expand Up @@ -511,12 +511,12 @@
<float.h>
<ieeefp.h>

1562359383 source:e:\dev\wxted-github\wxted\helpframe.cpp
1581098828 source:e:\dev\wxted-github\wxted\helpframe.cpp
"HelpFrame.h"
<wx/intl.h>
<wx/string.h>

1427407161 e:\dev\wxted-github\wxted\helpframe.h
1581098733 e:\dev\wxted-github\wxted\helpframe.h
<wx/frame.h>
<wx/html/htmlwin.h>

Expand Down Expand Up @@ -2273,18 +2273,18 @@

1483012312 e:\dev\wxted-github\wxted\ttxcodes.h

1563221963 e:\dev\wxted-github\wxted\ttxline.h
1581183494 e:\dev\wxted-github\wxted\ttxline.h
<iostream>
<string>
<iomanip>
"ttxcodes.h"

1463302150 e:\dev\wxted-github\wxted\hamm-tables.h

1574286336 source:e:\dev\wxted-github\wxted\ttxline.cpp
1581183665 source:e:\dev\wxted-github\wxted\ttxline.cpp
"ttxline.h"

1578743876 source:e:\dev\wxted-github\wxted\ttxpage.cpp
1581186632 source:e:\dev\wxted-github\wxted\ttxpage.cpp
"ttxpage.h"

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

1578693868 source:e:\dev\wxted-github\wxted\wxtedmain.cpp
1581100971 source:e:\dev\wxted-github\wxted\wxtedmain.cpp
"wxTEDMain.h"
<wx/msgdlg.h>
"wx/wx.h"
Expand Down
Loading

0 comments on commit d222394

Please sign in to comment.