Skip to content

Commit

Permalink
v1.45 Added Insert/Delete line
Browse files Browse the repository at this point in the history
Insert and Delete line added to the menu options. Can't be bothered implement ESC-I option because object orientated reasons. Also Undo/Redo is not available on these commands.
  • Loading branch information
peterkvt80 committed Jan 11, 2020
1 parent 03bf74d commit 3be3ad0
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 22 deletions.
29 changes: 27 additions & 2 deletions ttxpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Description : Class for a teletext page
* Compiler : C++
*
* Copyright (C) 2014-2018, Peter Kwan
* Copyright (C) 2014-2020, Peter Kwan
*
* Permission to use, copy, modify, and distribute this software
* and its documentation for any purpose and without fee is hereby
Expand Down Expand Up @@ -846,7 +846,7 @@ void TTXPage::SetCharAt(int code, int modifiers, wxPoint& cursorLoc, wxPoint& cu

if (modifiers & wxMOD_SHIFT) // Alpha Colours
{
char ch;
char ch=0;
// std::cout << "alpha colour Code=" << code << std::endl;
switch (code)
{
Expand All @@ -858,6 +858,7 @@ void TTXPage::SetCharAt(int code, int modifiers, wxPoint& cursorLoc, wxPoint& cu
case WXK_F6: ch=ttxCodeAlphaCyan;break; // Shift-F6 cyan
case WXK_F7: ch=ttxCodeAlphaWhite;break; // Shift-F7 white
case WXK_F8: ch=0x7f;break; // Shift-F8 black SPECIAL CASE!
// case WXK_F9: InsertLine(); break; // Oh. We don't have the y location at this point
default: ch=0; // not a valid shift code.
}
if (ch>0)
Expand Down Expand Up @@ -1501,3 +1502,27 @@ void TTXPage::SetFastextLink(int link, int value)
m_fastextlinks[link]=value;
}


// @todo This doesn't support undo/redo
void TTXPage::InsertLine(wxPoint& cursorLoc)
{
int y=cursorLoc.y;
for (int i=23;i>y;i--)
{
std::string line=GetRow(i-1)->GetLine();
SetRow(i, line);
}
SetRow(y," ");
}

// @todo This doesn't support undo/redo
void TTXPage::DeleteLine(wxPoint& cursorLoc)
{
int y=cursorLoc.y;
for (int i=y;i<23;i++)
{
std::string line=GetRow(i+1)->GetLine();
SetRow(i, line);
}
SetRow(23," ");
}
9 changes: 9 additions & 0 deletions ttxpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,15 @@ class TTXPage
bool GetPageChanged(){return pageChanged;};
void SetPageChanged(bool change){pageChanged=change;};

/** Insert a line below the line number indicated in cursorLoc
* and leave the current row blank
*/
void InsertLine(wxPoint& cursorLoc);
/** Delete a line below the current line and shift lower lines up one
* and leave the last row blank
*/
void DeleteLine(wxPoint& cursorLoc);

protected:
private:
static bool pageChanged; // / True if we have done some edits (on any subpage)
Expand Down
8 changes: 4 additions & 4 deletions wxTED.depend
Original file line number Diff line number Diff line change
Expand Up @@ -2254,7 +2254,7 @@
"string.h"
"ttxpage.h"

1563228741 e:\dev\wxted-github\wxted\ttxpage.h
1578742855 e:\dev\wxted-github\wxted\ttxpage.h
<stdlib.h>
"string.h"
<iostream>
Expand Down Expand Up @@ -2284,7 +2284,7 @@
1574286336 source:e:\dev\wxted-github\wxted\ttxline.cpp
"ttxline.h"

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

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

1578594888 e:\dev\wxted-github\wxted\wxtedmain.h
1578744529 e:\dev\wxted-github\wxted\wxtedmain.h
<wx/notebook.h>
<wx/menu.h>
<wx/panel.h>
Expand Down Expand Up @@ -2797,7 +2797,7 @@
"wx/dynarray.h"
"wx/vidmode.h"

1578693289 source:e:\dev\wxted-github\wxted\wxtedmain.cpp
1578693868 source:e:\dev\wxted-github\wxted\wxtedmain.cpp
"wxTEDMain.h"
<wx/msgdlg.h>
"wx/wx.h"
Expand Down
18 changes: 4 additions & 14 deletions wxTEDMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ void wxTEDFrame::OnChar(wxKeyEvent& event)
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 'i': modifiers=wxMOD_SHIFT; code=WXK_F9;break; // insert line
case 'I': modifiers=wxMOD_CONTROL; code=WXK_F9;break; // delete line
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
Expand Down Expand Up @@ -2641,25 +2643,13 @@ void wxTEDFrame::OnMenuNewFromTemplate(wxCommandEvent& event)
// @todo Map this to ESC-I
void wxTEDFrame::OnMenuDeleteLineSelected(wxCommandEvent& event)
{
int y=m_cursorPoint.y;
for (int i=y;i<23;i++)
{
std::string line=m_currentPage->GetRow(i+1)->GetLine();
m_currentPage->SetRow(i, line);
}
m_currentPage->SetRow(23," ");
m_currentPage->DeleteLine(m_cursorPoint);
}

// Scroll lines below down one, and leave current line blank
// Fastext row is NOT included
// @todo Map ESC-i onto this
void wxTEDFrame::OnMenuInsertLineSelected(wxCommandEvent& event)
{
int y=m_cursorPoint.y;
for (int i=23;i>y;i--)
{
std::string line=m_currentPage->GetRow(i-1)->GetLine();
m_currentPage->SetRow(i, line);
}
m_currentPage->SetRow(y," ");
m_currentPage->InsertLine(m_cursorPoint);
}
4 changes: 2 additions & 2 deletions wxTEDMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Purpose: Defines Application Frame
* Author: Peter Kwan ([email protected])
* Created: 2014-10-30
* Copyright: Peter Kwan (c) 2014-2019
* Copyright: Peter Kwan (c) 2014-2020
* License:
*
* Permission to use, copy, modify, and distribute this software
Expand Down Expand Up @@ -55,7 +55,7 @@
#include "mapchar.h"

// Version number
#define VERSION_STRING wxT("1.44")
#define VERSION_STRING wxT("1.45")

// ftp
#include <wininet.h>
Expand Down

0 comments on commit 3be3ad0

Please sign in to comment.