Skip to content

Commit

Permalink
Added ability to display strike-through text
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgammon committed Sep 3, 2016
1 parent d1b1821 commit 08382b6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
3 changes: 2 additions & 1 deletion OtherTypes.h
Expand Up @@ -260,11 +260,12 @@ typedef CTypedPtrList <CPtrList, CAction*> CActionList;
#define BLINK 0x0004 // italic??
#define INVERSE 0x0008 // need to invert it
#define CHANGED 0x0010 // colour has been changed by a trigger
#define STRIKEOUT 0x0020 // strike-though? (strikeout)
#define COLOURTYPE 0x0300 // type of colour in iForeColour/iBackColour, see above
#define ACTIONTYPE 0x0C00 // action type, see above
#define STYLE_BITS 0x0FFF // everything except START_TAG
#define START_TAG 0x1000 // strAction is tag name - start of tag (eg. <b> )
#define TEXT_STYLE 0x000F // bold, underline, italic, inverse flags
#define TEXT_STYLE 0x002F // bold, underline, italic, inverse, strike-through flags

// eg. <send "command1|command2|command3" hint="click to see menu|Item 1|Item 2|Item 2">this is a menu link</SEND>

Expand Down
10 changes: 5 additions & 5 deletions doc.cpp
Expand Up @@ -3265,7 +3265,7 @@ void CMUSHclientDoc::ChangeFont (const int nHeight,

int i;

for (i = 0; i < 8; i++)
for (i = 0; i < NUMITEMS (m_font); i++)
{
delete m_font [i]; // get rid of old font
m_font [i] = NULL;
Expand All @@ -3275,13 +3275,13 @@ int i;

dc.CreateCompatibleDC (NULL);

for (i = 0; i < 8; i++)
for (i = 0; i < NUMITEMS (m_font); i++)
{
m_font [i] = new CFont; // create new font

if (!m_font [i])
{
for (int j = 0; j < 8; j++)
for (int j = 0; j < NUMITEMS (m_font); j++)
{
delete m_font [j]; // get rid of old font
m_font [j] = NULL;
Expand All @@ -3301,15 +3301,15 @@ int i;
bShowBold ? ((i & HILITE) ? FW_BOLD : FW_NORMAL) : nWeight, // int nWeight,
bShowItalic ? (i & BLINK) != 0 : 0, // BYTE bItalic,
bShowUnderline ? (i & UNDERLINE) != 0 : 0, // BYTE bUnderline,
0, // BYTE cStrikeOut,
i >= 8, // BYTE cStrikeOut,
iFontCharset, // BYTE nCharSet,
0, // BYTE nOutPrecision,
0, // BYTE nClipPrecision,
0, // BYTE nQuality,
MUSHCLIENT_FONT_FAMILY, // BYTE nPitchAndFamily, // was FF_DONTCARE
lpszFacename);// LPCTSTR lpszFacename );

} // end of allocating 8 fonts
} // end of allocating 16 fonts

// Get the metrics of the font - use the bold one - it will probably be wider

Expand Down
2 changes: 1 addition & 1 deletion doc.h
Expand Up @@ -1167,7 +1167,7 @@ class CMUSHclientDoc : public CDocument
CString m_logfile_name;
CTime m_LastFlushTime;

CFont * m_font [8]; // 8 fonts - normal, bold, italic, bold-normal etc.
CFont * m_font [16]; // 16 fonts - normal, bold, italic, bold-normal etc.
int m_FontHeight,
m_FontWidth;

Expand Down
4 changes: 2 additions & 2 deletions doc_construct.cpp
Expand Up @@ -189,7 +189,7 @@ int i;
ASSERT(CWnd::FromHandlePermanent(m_pTimerWnd->m_hWnd) == m_pTimerWnd);


for (i = 0; i < 8; i++)
for (i = 0; i < NUMITEMS (m_font); i++)
m_font [i] = NULL;
m_input_font = NULL;
m_FontHeight = 0;
Expand Down Expand Up @@ -493,7 +493,7 @@ int i;
m_pTimerWnd = NULL;
}

for (i = 0; i < 8; i++)
for (i = 0; i < NUMITEMS (m_font); i++)
delete m_font [i];
delete m_input_font;

Expand Down
18 changes: 13 additions & 5 deletions mushview.cpp
Expand Up @@ -362,9 +362,12 @@ CLine * pLine = pDoc->m_LineList.GetAt (pDoc->GetLinePosition (line));

// select appropriate font

if (pDoc->m_font [pStyle->iFlags & 7])
dc.SelectObject(pDoc->m_font [pStyle->iFlags & 7]);

int styleIndex = pStyle->iFlags & 7;
// strikeout fonts are 8 to 15
if (pStyle->iFlags & STRIKEOUT)
styleIndex += 8;
if (pDoc->m_font [styleIndex])
dc.SelectObject(pDoc->m_font [styleIndex]);

if (pDoc->m_bUTF_8)
{
Expand Down Expand Up @@ -456,8 +459,13 @@ POSITION foundpos;
// don't overshoot
thislen = MIN (cols_to_go, thislen);

if (pDoc->m_font [pStyle->iFlags & 7])
pDC->SelectObject(pDoc->m_font [pStyle->iFlags & 7]);
int styleIndex = pStyle->iFlags & 7;
// strikeout fonts are 8 to 15
if (pStyle->iFlags & STRIKEOUT)
styleIndex += 8;

if (pDoc->m_font [styleIndex])
pDC->SelectObject(pDoc->m_font [styleIndex]);

pDoc->GetStyleRGB (pStyle, colour1, colour2);

Expand Down

0 comments on commit 08382b6

Please sign in to comment.