Add optional MouseText-to-ASCII conversion

The AWP5 MouseText output is okay for some things but not others.
This adds an ASCII conversion, enabled through a preference.
This commit is contained in:
Andy McFadden 2017-11-13 14:24:58 -08:00
parent 3d88397024
commit 2adbe9591f
17 changed files with 114 additions and 59 deletions

View File

@ -320,12 +320,12 @@ BEGIN
PUSHBUTTON "Help",IDHELP,376,242,50,14 PUSHBUTTON "Help",IDHELP,376,242,50,14
END END
IDD_PREF_FVIEW DIALOGEX 0, 0, 216, 263 IDD_PREF_FVIEW DIALOGEX 0, 0, 217, 274
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTEXTHELP | WS_CHILD | WS_CAPTION STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTEXTHELP | WS_CHILD | WS_CAPTION
CAPTION "File Viewer" CAPTION "File Viewer"
FONT 8, "MS Shell Dlg", 0, 0, 0x0 FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN BEGIN
GROUPBOX "Converters",IDC_STATIC,4,7,208,139 GROUPBOX "Converters",IDC_STATIC,4,7,209,139
CONTROL "High-ASCII &text",IDC_PVIEW_HITEXT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,19,88,10 CONTROL "High-ASCII &text",IDC_PVIEW_HITEXT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,19,88,10
CONTROL "&CP/M text",IDC_PVIEW_CPMTEXT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,30,92,10 CONTROL "&CP/M text",IDC_PVIEW_CPMTEXT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,30,92,10
CONTROL "&Pascal text",IDC_PVIEW_PASCALTEXT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,41,87,10 CONTROL "&Pascal text",IDC_PVIEW_PASCALTEXT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,41,87,10
@ -348,7 +348,7 @@ BEGIN
CONTROL "MacPaint images",IDC_PVIEW_MACPAINT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,112,118,93,10 CONTROL "MacPaint images",IDC_PVIEW_MACPAINT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,112,118,93,10
CONTROL "&Relax type-checking on graphics",IDC_PVIEW_RELAX_GFX, CONTROL "&Relax type-checking on graphics",IDC_PVIEW_RELAX_GFX,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,50,131,116,10 "Button",BS_AUTOCHECKBOX | WS_TABSTOP,50,131,116,10
GROUPBOX "Conversion options",IDC_STATIC,4,150,208,90 GROUPBOX "Conversion options",IDC_STATIC,4,150,209,101
CONTROL "&Scroll horizontally instead of wrapping words",IDC_PVIEW_NOWRAP_TEXT, CONTROL "&Scroll horizontally instead of wrapping words",IDC_PVIEW_NOWRAP_TEXT,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,162,192,10 "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,162,192,10
CONTROL "Highlight &hex dump columns (small files)",IDC_PVIEW_BOLD_HEXDUMP, CONTROL "Highlight &hex dump columns (small files)",IDC_PVIEW_BOLD_HEXDUMP,
@ -359,12 +359,14 @@ BEGIN
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,195,189,10 "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,195,189,10
CONTROL "Prefer &B&&W for hi-res images",IDC_PVIEW_HIRES_BW, CONTROL "Prefer &B&&W for hi-res images",IDC_PVIEW_HIRES_BW,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,206,148,10 "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,206,148,10
LTEXT "Preferred DHR mode:",IDC_STATIC,12,223,69,8 CONTROL "Convert MouseText to ASCII",IDC_PVIEW_MOUSETEXT_TO_ASCII,
COMBOBOX IDC_PVIEW_DHR_CONV_COMBO,84,220,118,48,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,217,194,10
LTEXT "Viewer file size &limit:",IDC_STATIC,4,247,62,8 LTEXT "Preferred DHR mode:",IDC_STATIC,12,234,69,8
EDITTEXT IDC_PVIEW_SIZE_EDIT,69,245,40,14,ES_AUTOHSCROLL | ES_NUMBER COMBOBOX IDC_PVIEW_DHR_CONV_COMBO,84,231,118,48,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
CONTROL "Spin2",IDC_PVIEW_SIZE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,112,247,11,14 LTEXT "Viewer file size &limit:",IDC_STATIC,4,258,62,8
LTEXT "KBytes",IDC_STATIC,110,247,36,8 EDITTEXT IDC_PVIEW_SIZE_EDIT,69,256,40,14,ES_AUTOHSCROLL | ES_NUMBER
CONTROL "Spin2",IDC_PVIEW_SIZE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,112,258,11,14
LTEXT "KBytes",IDC_STATIC,110,258,36,8
END END
IDD_DISKEDIT DIALOGEX 0, 0, 458, 197 IDD_DISKEDIT DIALOGEX 0, 0, 458, 197
@ -1362,12 +1364,12 @@ BEGIN
IDD_PREF_FVIEW, DIALOG IDD_PREF_FVIEW, DIALOG
BEGIN BEGIN
LEFTMARGIN, 4 LEFTMARGIN, 4
RIGHTMARGIN, 212 RIGHTMARGIN, 213
VERTGUIDE, 12 VERTGUIDE, 12
VERTGUIDE, 50 VERTGUIDE, 50
VERTGUIDE, 112 VERTGUIDE, 112
TOPMARGIN, 7 TOPMARGIN, 7
BOTTOMMARGIN, 261 BOTTOMMARGIN, 272
END END
IDD_DISKEDIT, DIALOG IDD_DISKEDIT, DIALOG
@ -1863,6 +1865,11 @@ BEGIN
0 0
END END
IDD_PREF_FVIEW AFX_DIALOG_LAYOUT
BEGIN
0
END
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //

Binary file not shown.

View File

@ -82,6 +82,9 @@ If enabled, hi-res graphics are converted to black & white images by default.
.topic IDH_PVIEW_DHR_CONV_COMBO .topic IDH_PVIEW_DHR_CONV_COMBO
Selects the preferred conversion algorithm for double-hi-res graphics. Selects the preferred conversion algorithm for double-hi-res graphics.
.topic IDH_PVIEW_MOUSETEXT_TO_ASCII
Converts MouseText to ASCII instead of Unicode symbols.
.topic IDH_PVIEW_HITEXT .topic IDH_PVIEW_HITEXT
Enables the text converter, which strips "high ASCII" text and converts end-of-line characters. Enables the text converter, which strips "high ASCII" text and converts end-of-line characters.

View File

@ -28,6 +28,7 @@
#define IDH_PVIEW_DISASM_ONEBYTEBRKCOP 1028 #define IDH_PVIEW_DISASM_ONEBYTEBRKCOP 1028
#define IDH_PVIEW_HIRES_BW 1029 #define IDH_PVIEW_HIRES_BW 1029
#define IDH_PVIEW_DHR_CONV_COMBO 1030 #define IDH_PVIEW_DHR_CONV_COMBO 1030
#define IDH_PVIEW_MOUSETEXT_TO_ASCII 1031
#define IDH_PVIEW_HITEXT 1036 #define IDH_PVIEW_HITEXT 1036
#define IDH_PVIEW_PASCALTEXT 1037 #define IDH_PVIEW_PASCALTEXT 1037
#define IDH_PVIEW_APPLESOFT 1038 #define IDH_PVIEW_APPLESOFT 1038

View File

@ -11,3 +11,5 @@ This should update the CiderPress.chm in the app/Help directory. You can
copy it into the CiderPress directory, or just rebuild CiderPress to have copy it into the CiderPress directory, or just rebuild CiderPress to have
it copied automatically. it copied automatically.
NOTE: pop-up text must be added to PopUp.txt, PopUpIds.h, and the
PopUpHelpIds table in MyApp.cpp.

View File

@ -827,6 +827,7 @@ void MainWindow::OnEditPreferences(void)
ps.fFviewPage.fHighlightHexDump = fPreferences.GetPrefBool(kPrHighlightHexDump); ps.fFviewPage.fHighlightHexDump = fPreferences.GetPrefBool(kPrHighlightHexDump);
ps.fFviewPage.fHighlightBASIC = fPreferences.GetPrefBool(kPrHighlightBASIC); ps.fFviewPage.fHighlightBASIC = fPreferences.GetPrefBool(kPrHighlightBASIC);
ps.fFviewPage.fConvDisasmOneByteBrkCop = fPreferences.GetPrefBool(kPrDisasmOneByteBrkCop); ps.fFviewPage.fConvDisasmOneByteBrkCop = fPreferences.GetPrefBool(kPrDisasmOneByteBrkCop);
ps.fFviewPage.fConvMouseTextToASCII = fPreferences.GetPrefBool(kPrConvMouseTextToASCII);
ps.fFviewPage.fConvHiResBlackWhite = fPreferences.GetPrefBool(kPrConvHiResBlackWhite); ps.fFviewPage.fConvHiResBlackWhite = fPreferences.GetPrefBool(kPrConvHiResBlackWhite);
ps.fFviewPage.fConvDHRAlgorithm = fPreferences.GetPrefLong(kPrConvDHRAlgorithm); ps.fFviewPage.fConvDHRAlgorithm = fPreferences.GetPrefLong(kPrConvDHRAlgorithm);
ps.fFviewPage.fRelaxGfxTypeCheck = fPreferences.GetPrefBool(kPrRelaxGfxTypeCheck); ps.fFviewPage.fRelaxGfxTypeCheck = fPreferences.GetPrefBool(kPrRelaxGfxTypeCheck);
@ -955,6 +956,7 @@ void MainWindow::ApplyNow(PrefsSheet* pPS)
fPreferences.SetPrefBool(kPrHighlightHexDump, pPS->fFviewPage.fHighlightHexDump != 0); fPreferences.SetPrefBool(kPrHighlightHexDump, pPS->fFviewPage.fHighlightHexDump != 0);
fPreferences.SetPrefBool(kPrHighlightBASIC, pPS->fFviewPage.fHighlightBASIC != 0); fPreferences.SetPrefBool(kPrHighlightBASIC, pPS->fFviewPage.fHighlightBASIC != 0);
fPreferences.SetPrefBool(kPrDisasmOneByteBrkCop, pPS->fFviewPage.fConvDisasmOneByteBrkCop != 0); fPreferences.SetPrefBool(kPrDisasmOneByteBrkCop, pPS->fFviewPage.fConvDisasmOneByteBrkCop != 0);
fPreferences.SetPrefBool(kPrConvMouseTextToASCII, pPS->fFviewPage.fConvMouseTextToASCII != 0);
fPreferences.SetPrefBool(kPrConvHiResBlackWhite, pPS->fFviewPage.fConvHiResBlackWhite != 0); fPreferences.SetPrefBool(kPrConvHiResBlackWhite, pPS->fFviewPage.fConvHiResBlackWhite != 0);
fPreferences.SetPrefLong(kPrConvDHRAlgorithm, pPS->fFviewPage.fConvDHRAlgorithm); fPreferences.SetPrefLong(kPrConvDHRAlgorithm, pPS->fFviewPage.fConvDHRAlgorithm);
fPreferences.SetPrefBool(kPrRelaxGfxTypeCheck, pPS->fFviewPage.fRelaxGfxTypeCheck != 0); fPreferences.SetPrefBool(kPrRelaxGfxTypeCheck, pPS->fFviewPage.fRelaxGfxTypeCheck != 0);
@ -2465,6 +2467,8 @@ CString MainWindow::RemoveFile(const WCHAR* fileName)
pPreferences->GetPrefBool(kPrRelaxGfxTypeCheck)); pPreferences->GetPrefBool(kPrRelaxGfxTypeCheck));
pReformat->SetOption(ReformatHolder::kOptOneByteBrkCop, pReformat->SetOption(ReformatHolder::kOptOneByteBrkCop,
pPreferences->GetPrefBool(kPrDisasmOneByteBrkCop)); pPreferences->GetPrefBool(kPrDisasmOneByteBrkCop));
pReformat->SetOption(ReformatHolder::kOptMouseTextToASCII,
pPreferences->GetPrefBool(kPrConvMouseTextToASCII));
} }
/*static*/ ReformatHolder::SourceFormat MainWindow::ReformatterSourceFormat( /*static*/ ReformatHolder::SourceFormat MainWindow::ReformatterSourceFormat(

View File

@ -201,6 +201,7 @@ BOOL MyApp::OnIdle(LONG lCount)
IDC_PVIEW_DISASM_ONEBYTEBRKCOP, IDH_PVIEW_DISASM_ONEBYTEBRKCOP, IDC_PVIEW_DISASM_ONEBYTEBRKCOP, IDH_PVIEW_DISASM_ONEBYTEBRKCOP,
IDC_PVIEW_HIRES_BW, IDH_PVIEW_HIRES_BW, IDC_PVIEW_HIRES_BW, IDH_PVIEW_HIRES_BW,
IDC_PVIEW_DHR_CONV_COMBO, IDH_PVIEW_DHR_CONV_COMBO, IDC_PVIEW_DHR_CONV_COMBO, IDH_PVIEW_DHR_CONV_COMBO,
IDC_PVIEW_MOUSETEXT_TO_ASCII, IDH_PVIEW_MOUSETEXT_TO_ASCII,
IDC_PVIEW_HITEXT, IDH_PVIEW_HITEXT, IDC_PVIEW_HITEXT, IDH_PVIEW_HITEXT,
IDC_PVIEW_PASCALTEXT, IDH_PVIEW_PASCALTEXT, IDC_PVIEW_PASCALTEXT, IDH_PVIEW_PASCALTEXT,
IDC_PVIEW_APPLESOFT, IDH_PVIEW_APPLESOFT, IDC_PVIEW_APPLESOFT, IDH_PVIEW_APPLESOFT,

View File

@ -108,6 +108,7 @@ const Preferences::PrefMap Preferences::fPrefMaps[kPrefNumLastEntry] = {
{ kPrConvDHRAlgorithm, kLong, kPrefsSect, L"dhr-algorithm" }, { kPrConvDHRAlgorithm, kLong, kPrefsSect, L"dhr-algorithm" },
{ kPrRelaxGfxTypeCheck, kBool, kPrefsSect, L"relax-gfx-type-check" }, { kPrRelaxGfxTypeCheck, kBool, kPrefsSect, L"relax-gfx-type-check" },
{ kPrDisasmOneByteBrkCop, kBool, kPrefsSect, L"disasm-onebytebrkcop" }, { kPrDisasmOneByteBrkCop, kBool, kPrefsSect, L"disasm-onebytebrkcop" },
{ kPrConvMouseTextToASCII, kBool, kPrefsSect, L"conv-mouse-text-to-ascii" },
//{ kPrEOLConvRaw, kBool, kPrefsSect, L"eol-conv-raw" }, //{ kPrEOLConvRaw, kBool, kPrefsSect, L"eol-conv-raw" },
{ kPrConvTextEOL_HA, kBool, kPrefsSect, L"conv-eol-ha" }, { kPrConvTextEOL_HA, kBool, kPrefsSect, L"conv-eol-ha" },
{ kPrConvPascalText, kBool, kPrefsSect, L"conv-pascal-text" }, { kPrConvPascalText, kBool, kPrefsSect, L"conv-pascal-text" },
@ -214,6 +215,7 @@ Preferences::Preferences(void)
SetPrefLong(kPrConvDHRAlgorithm, 1); // latched SetPrefLong(kPrConvDHRAlgorithm, 1); // latched
SetPrefBool(kPrRelaxGfxTypeCheck, true); SetPrefBool(kPrRelaxGfxTypeCheck, true);
SetPrefBool(kPrDisasmOneByteBrkCop, false); SetPrefBool(kPrDisasmOneByteBrkCop, false);
SetPrefBool(kPrConvMouseTextToASCII, false);
//SetPrefBool(kPrEOLConvRaw, true); //SetPrefBool(kPrEOLConvRaw, true);
SetPrefBool(kPrConvTextEOL_HA, true); SetPrefBool(kPrConvTextEOL_HA, true);
SetPrefBool(kPrConvPascalText, true); SetPrefBool(kPrConvPascalText, true);

View File

@ -12,6 +12,13 @@
* section to the registry if appropriate. * section to the registry if appropriate.
* - Add a default value to Preferences::Preferences. If not specified, * - Add a default value to Preferences::Preferences. If not specified,
* strings will be NULL and numeric values will be zero. * strings will be NULL and numeric values will be zero.
*
* For user-settable preferencers, you must also:
* - Add a UI element to the appropriate preference page.
* - Add the appropriate code for that item. Note in particular the data
* exchange and ON_CONTROL_RANGE values.
* - In Main.cpp, update OnEditPreferences() to init the page.
* - Add a tooltip to the help file.
*/ */
#ifndef APP_PREFERENCES_H #ifndef APP_PREFERENCES_H
#define APP_PREFERENCES_H #define APP_PREFERENCES_H
@ -168,6 +175,7 @@ typedef enum {
kPrConvDHRAlgorithm, // long kPrConvDHRAlgorithm, // long
kPrRelaxGfxTypeCheck, // bool kPrRelaxGfxTypeCheck, // bool
kPrDisasmOneByteBrkCop, // bool kPrDisasmOneByteBrkCop, // bool
kPrConvMouseTextToASCII, // bool
//kPrEOLConvRaw, // bool //kPrEOLConvRaw, // bool
kPrConvTextEOL_HA, // bool kPrConvTextEOL_HA, // bool
kPrConvPascalText, // bool kPrConvPascalText, // bool

View File

@ -316,6 +316,7 @@ void PrefsFviewPage::DoDataExchange(CDataExchange* pDX)
DDX_Check(pDX, IDC_PVIEW_BOLD_HEXDUMP, fHighlightHexDump); DDX_Check(pDX, IDC_PVIEW_BOLD_HEXDUMP, fHighlightHexDump);
DDX_Check(pDX, IDC_PVIEW_BOLD_BASIC, fHighlightBASIC); DDX_Check(pDX, IDC_PVIEW_BOLD_BASIC, fHighlightBASIC);
DDX_Check(pDX, IDC_PVIEW_DISASM_ONEBYTEBRKCOP, fConvDisasmOneByteBrkCop); DDX_Check(pDX, IDC_PVIEW_DISASM_ONEBYTEBRKCOP, fConvDisasmOneByteBrkCop);
DDX_Check(pDX, IDC_PVIEW_MOUSETEXT_TO_ASCII, fConvMouseTextToASCII);
DDX_Check(pDX, IDC_PVIEW_HIRES_BW, fConvHiResBlackWhite); DDX_Check(pDX, IDC_PVIEW_HIRES_BW, fConvHiResBlackWhite);
DDX_CBIndex(pDX, IDC_PVIEW_DHR_CONV_COMBO, fConvDHRAlgorithm); DDX_CBIndex(pDX, IDC_PVIEW_DHR_CONV_COMBO, fConvDHRAlgorithm);

View File

@ -168,6 +168,7 @@ public:
BOOL fHighlightHexDump; BOOL fHighlightHexDump;
BOOL fHighlightBASIC; BOOL fHighlightBASIC;
BOOL fConvDisasmOneByteBrkCop; BOOL fConvDisasmOneByteBrkCop;
BOOL fConvMouseTextToASCII;
BOOL fConvHiResBlackWhite; BOOL fConvHiResBlackWhite;
int fConvDHRAlgorithm; // drop list int fConvDHRAlgorithm; // drop list

View File

@ -93,6 +93,7 @@
#define IDC_PVIEW_DISASM_ONEBYTEBRKCOP 1028 #define IDC_PVIEW_DISASM_ONEBYTEBRKCOP 1028
#define IDC_PVIEW_HIRES_BW 1029 #define IDC_PVIEW_HIRES_BW 1029
#define IDC_PVIEW_DHR_CONV_COMBO 1030 #define IDC_PVIEW_DHR_CONV_COMBO 1030
#define IDC_PVIEW_MOUSETEXT_TO_ASCII 1031
#define IDC_PVIEW_HITEXT 1036 #define IDC_PVIEW_HITEXT 1036
#define IDC_PVIEW_PASCALTEXT 1037 #define IDC_PVIEW_PASCALTEXT 1037
#define IDC_PVIEW_APPLESOFT 1038 #define IDC_PVIEW_APPLESOFT 1038
@ -559,9 +560,9 @@
// //
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 193 #define _APS_NEXT_RESOURCE_VALUE 196
#define _APS_NEXT_COMMAND_VALUE 40102 #define _APS_NEXT_COMMAND_VALUE 40102
#define _APS_NEXT_CONTROL_VALUE 1454 #define _APS_NEXT_CONTROL_VALUE 1455
#define _APS_NEXT_SYMED_VALUE 102 #define _APS_NEXT_SYMED_VALUE 102
#endif #endif
#endif #endif

View File

@ -69,6 +69,8 @@ int ReformatAWP::Process(const ReformatHolder* pHolder,
bool skipRecord; bool skipRecord;
uint8_t lineRecCode, lineRecData; uint8_t lineRecCode, lineRecData;
fMouseTextToASCII = pHolder->GetOption(ReformatHolder::kOptMouseTextToASCII) != 0;
if (srcLen > 65536) if (srcLen > 65536)
fUseRTF = false; fUseRTF = false;
@ -457,8 +459,12 @@ int ReformatAWP::HandleTextRecord(uint8_t lineRecData,
wantInverse = true; wantInverse = true;
} else if (ic >= 0xc0 && ic <= 0xdf) { } else if (ic >= 0xc0 && ic <= 0xdf) {
// MouseText characters // MouseText characters
MouseTextToUTF16(ic & 0x1f, &mtLow, &mtHigh); if (fMouseTextToASCII) {
ic = '?'; ic = MouseTextToASCII(ic & 0x1f);
} else {
MouseTextToUTF16(ic & 0x1f, &mtLow, &mtHigh);
ic = '?';
}
} else { } else {
// plain ASCII // plain ASCII
} }

View File

@ -16,7 +16,10 @@
*/ */
class ReformatAWP : public ReformatText { class ReformatAWP : public ReformatText {
public: public:
ReformatAWP(void) { fShowEmbeds = true; } ReformatAWP(void)
: fShowEmbeds(true),
fMouseTextToASCII(false)
{}
virtual ~ReformatAWP(void) {} virtual ~ReformatAWP(void) {}
virtual void Examine(ReformatHolder* pHolder) override; virtual void Examine(ReformatHolder* pHolder) override;
@ -146,6 +149,7 @@ private:
FileHeader fFileHeader; FileHeader fFileHeader;
DocState fDocState; DocState fDocState;
bool fShowEmbeds; bool fShowEmbeds;
bool fMouseTextToASCII;
}; };
/* /*

View File

@ -143,6 +143,7 @@ public:
kOptDHRAlgorithm, kOptDHRAlgorithm,
kOptRelaxGfxTypeCheck, kOptRelaxGfxTypeCheck,
kOptOneByteBrkCop, kOptOneByteBrkCop,
kOptMouseTextToASCII,
kOptMAX // must be last kOptMAX // must be last
} OptionID; } OptionID;
@ -186,7 +187,7 @@ public:
* We want to know if it's DOS so we can relax some file-type checking, * We want to know if it's DOS so we can relax some file-type checking,
* and we want to know if it's CP/M so we can adjust the way we think * and we want to know if it's CP/M so we can adjust the way we think
* about text files. We want to know if it's Gutenberg because they only * about text files. We want to know if it's Gutenberg because they only
* have one type of file, and it's indistingusihable from any other text file! * have one type of file, and it's indistinguishable from any other text file!
*/ */
typedef enum SourceFormat { typedef enum SourceFormat {
kSourceFormatGeneric = 0, kSourceFormatGeneric = 0,

View File

@ -608,7 +608,7 @@ void ReformatText::ConvertEOL(const uint8_t* srcBuf, long srcLen,
* *
* If "stripHiBits" is set, the high bit of each character is cleared before * If "stripHiBits" is set, the high bit of each character is cleared before
* the value is considered. * the value is considered.
*2 *
* If "stripNulls" is true, no null values will make it through. * If "stripNulls" is true, no null values will make it through.
*/ */
void ReformatText::ConvertEOL(const uint8_t* srcBuf, long srcLen, void ReformatText::ConvertEOL(const uint8_t* srcBuf, long srcLen,
@ -743,51 +743,59 @@ void ReformatText::BufHexDump(const uint8_t* srcBuf, long srcLen)
} }
} }
// Thanks to: http://hoop-la.ca/apple2/docs/mousetext/unicode.html // Thanks to http://hoop-la.ca/apple2/docs/mousetext/unicode.html for Unicode.
static const uint32_t gMouseTextConv[32] = { // Thanks to Hugh Hood for extracting the ASCII conversions from SEG.WP.
0xd83cdf4e, // 00 U+1f34e RED APPLE static const struct {
0xd83cdf4f, // 01 U+1f34f GREEN APPLE uint32_t unicode; // UTF-16 single code point or surrogate pair
//0x00002316, // 02 U+2316 POSITION INDICATOR int8_t ascii; // 7-bit ASCII
0x000025c4, // 02 U+25c4 BLACK LEFT-POINTING POINTER } gMouseTextConv[32] = {
0x000023f3, // 03 U+23f3 HOURGLASS WITH FLOWING SAND { 0xd83cdf4e, '@' }, // 00 U+1f34e RED APPLE
0x00002713, // 04 U+2713 CHECK MARK { 0xd83cdf4f, '@' }, // 01 U+1f34f GREEN APPLE
0x00002705, // 05 U+2705 WHITE HEAVY CHECK MARK //{ 0x00002316, '^' }, // 02 U+2316 POSITION INDICATOR
0x000023ce, // 06 U+23ce RETURN SYMBOL { 0x000025c4, '^' }, // 02 U+25c4 BLACK LEFT-POINTING POINTER
//0xd83cdf54, // 07 U+1f354 HAMBURGER { 0x000023f3, '&' }, // 03 U+23f3 HOURGLASS WITH FLOWING SAND
0x00002630, // 07 U+2630 TRIGRAM FOR HEAVEN (actually want 4 lines, not 3) { 0x00002713, '\'' }, // 04 U+2713 CHECK MARK
0x00002190, // 08 U+2190 LEFTWARDS ARROW { 0x00002705, '\'' }, // 05 U+2705 WHITE HEAVY CHECK MARK
0x00002026, // 09 U+2026 HORIZONTAL ELLIPSIS { 0x000023ce, '/' }, // 06 U+23ce RETURN SYMBOL
0x00002193, // 0a U+2193 DOWNWARDS ARROW //{ 0xd83cdf54, ':' }, // 07 U+1f354 HAMBURGER
0x00002191, // 0b U+2191 UPWARDS ARROW { 0x00002630, ':' }, // 07 U+2630 TRIGRAM FOR HEAVEN (actually want 4 lines, not 3)
0x00002594, // 0c U+2594 UPPER ONE EIGHTH BLOCK { 0x00002190, '<' }, // 08 U+2190 LEFTWARDS ARROW
0x000021b5, // 0d U+21b5 DOWNWARDS ARROW WITH CORNER LEFTWARDS { 0x00002026, '_' }, // 09 U+2026 HORIZONTAL ELLIPSIS
0x00002589, // 0e U+2589 LEFT SEVEN EIGHTHS BLOCK { 0x00002193, 'v' }, // 0a U+2193 DOWNWARDS ARROW
0x000021e4, // 0f U+21e4 LEFTWARDS ARROW TO BAR { 0x00002191, '^' }, // 0b U+2191 UPWARDS ARROW
0x000021e5, // 10 U+21e5 RIGHTWARDS ARROW TO BAR { 0x00002594, '-' }, // 0c U+2594 UPPER ONE EIGHTH BLOCK
0x00002913, // 11 U+2913 DOWNWARDS ARROW TO BAR { 0x000021b5, '/' }, // 0d U+21b5 DOWNWARDS ARROW WITH CORNER LEFTWARDS
0x00002912, // 12 U+2912 UPWARDS ARROW TO BAR { 0x00002589, '$' }, // 0e U+2589 LEFT SEVEN EIGHTHS BLOCK
0x00002500, // 13 U+2500 BOX DRAWINGS LIGHT HORIZONTAL { 0x000021e4, '{' }, // 0f U+21e4 LEFTWARDS ARROW TO BAR
0x0000231e, // 14 U+231e BOTTOM LEFT CORNER { 0x000021e5, '}' }, // 10 U+21e5 RIGHTWARDS ARROW TO BAR
0x00002192, // 15 U+2192 UPWARDS ARROW TO BAR { 0x00002913, 'v' }, // 11 U+2913 DOWNWARDS ARROW TO BAR
//0xd83dde7e, // 16 U+1f67e CHECKER BOARD { 0x00002912, '^' }, // 12 U+2912 UPWARDS ARROW TO BAR
0x00002591, // 16 U+2591 LIGHT SHADE { 0x00002500, '-' }, // 13 U+2500 BOX DRAWINGS LIGHT HORIZONTAL
//0xd83dde7f, // 17 U+1f67f REVERSE CHECKER BOARD { 0x0000231e, 'L' }, // 14 U+231e BOTTOM LEFT CORNER
0x00002592, // 17 U+2592 MEDIUM SHADE { 0x00002192, '>' }, // 15 U+2192 UPWARDS ARROW TO BAR
0xd83ddcc1, // 18 U+1f4c1 FILE FOLDER //{ 0xd83dde7e, '*' }, // 16 U+1f67e CHECKER BOARD
0xd83ddcc2, // 19 U+1f4c2 OPEN FILE FOLDER { 0x00002591, '*' }, // 16 U+2591 LIGHT SHADE
0x00002595, // 1a U+2595 RIGHT ONE EIGHTH BLOCK //{ 0xd83dde7f, '*' }, // 17 U+1f67f REVERSE CHECKER BOARD
0x00002666, // 1b U+2666 BLACK DIAMOND SUIT { 0x00002592, '*' }, // 17 U+2592 MEDIUM SHADE
0x0000203e, // 1c U+203e OVERLINE -- wrong, want top/bottom { 0xd83ddcc1, '[' }, // 18 U+1f4c1 FILE FOLDER
0x0000256c, // 1d U+256c BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL { 0xd83ddcc2, ']' }, // 19 U+1f4c2 OPEN FILE FOLDER
//0xd83ddcbe, // 1e U+1f4be FLOPPY DISK { 0x00002595, '|' }, // 1a U+2595 RIGHT ONE EIGHTH BLOCK
0x000022a1, // 1e U+22a1 SQUARED DOT OPERATOR (seems better than 25a3) { 0x00002666, '#' }, // 1b U+2666 BLACK DIAMOND SUIT
0x0000258f, // 1f U+258f LEFT ONE EIGHTH BLOCK { 0x0000203e, '=' }, // 1c U+203e OVERLINE -- wrong, want top/bottom
{ 0x0000256c, '#' }, // 1d U+256c BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
//{ 0xd83ddcbe, 'O' }, // 1e U+1f4be FLOPPY DISK
{ 0x000022a1, 'O' }, // 1e U+22a1 SQUARED DOT OPERATOR (seems better than 25a3)
{ 0x0000258f, '|' }, // 1f U+258f LEFT ONE EIGHTH BLOCK
}; };
void ReformatText::MouseTextToUTF16(uint8_t mtVal, uint16_t* pLow, uint16_t* pHigh) { void ReformatText::MouseTextToUTF16(uint8_t mtVal, uint16_t* pLow, uint16_t* pHigh) {
ASSERT(mtVal < 32); ASSERT(mtVal < 32);
*pLow = gMouseTextConv[mtVal] & 0xffff; *pLow = gMouseTextConv[mtVal].unicode & 0xffff;
*pHigh = gMouseTextConv[mtVal] >> 16; *pHigh = gMouseTextConv[mtVal].unicode >> 16;
}
int8_t ReformatText::MouseTextToASCII(uint8_t mtVal) {
ASSERT(mtVal < 32);
return gMouseTextConv[mtVal].ascii;
} }

View File

@ -390,9 +390,14 @@ protected:
// encoding as a surrogate pair, high will be nonzero. // encoding as a surrogate pair, high will be nonzero.
void MouseTextToUTF16(uint8_t mtVal, uint16_t* pLow, uint16_t* pHigh); void MouseTextToUTF16(uint8_t mtVal, uint16_t* pLow, uint16_t* pHigh);
// Converts a MouseText value (0-31) to an ASCII equivalent. This is not
// a 1:1 conversion, so it's not reversible.
int8_t MouseTextToASCII(uint8_t mtVal);
private: private:
DECLARE_COPY_AND_OPEQ(ReformatText) DECLARE_COPY_AND_OPEQ(ReformatText)
int CreateWorkBuf(void); int CreateWorkBuf(void);
enum { kRTFUnitsPerInch = 1440 }; // TWIPS enum { kRTFUnitsPerInch = 1440 }; // TWIPS
int fLeftMargin, fRightMargin; // for documents, in 1/10th inch int fLeftMargin, fRightMargin; // for documents, in 1/10th inch