1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
/* $Id: cursesmoronize.H,v 1.2 2004/05/01 02:28:21 mrsam Exp $
**
** Copyright 2003-2004, Double Precision Inc.
**
** See COPYING for distribution information.
*/
#ifndef cursesmoronize_H
#define cursesmoronize_H
#include "mycurses.H"
#include <wchar.h>
///////////////////////////////////////////////////////////////////////////
//
// "Smart characters" processing, a.k.a. moronization
// Example: Convert typed "1/4" to the ISO-8859-1 character for 1/4.
//
class CursesMoronize {
public:
static size_t moronize(const char *buf, wchar_t &nreplaced);
//
// 'buf' should be the characters just preceding the current cursor
// position, IN REVERSE ORDER. So, if the cursor is now:
//
// ...1/4_ _ marks the cursor position
//
// ... then 'buf' should be '4/1...'. buf can be as long as the
// caller wants. We search for a suitable replacement using
// strncmp
//
// If found a replacement, returns non-zero chars to replace, and
// set nreplaced to the replacement character
class Entry {
public:
const char *keycode;
size_t keycodeLen;
wchar_t unicode_char;
};
static bool enabled;
static Entry moronizationList[];
};
#endif
|