/*********************************************************************
* SEGGER Microcontroller GmbH & Co. KG *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 1996 - 2010 SEGGER Microcontroller GmbH & Co. KG *
* *
* Internet: www.segger.com Support: support@segger.com *
* *
**********************************************************************
** emWin V5.06 - Graphical user interface for embedded applications **
emWin is protected by international copyright laws. Knowledge of the
source code may not be used to write a similar product. This file may
only be used in accordance with a license and should not be re-
distributed in any way. We appreciate your understanding and fairness.
----------------------------------------------------------------------
File : GUI__BiDi.c
Purpose : Implementation of the BiDi-algorithm explained in the
Unicode standard annex #9. Some code of this implementaion
is based on the Unicode reference code.
---------------------------END-OF-HEADER------------------------------
*/
#include "GUI_Private.h"
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#ifndef GUI_BIDI_MAX_LEVEL
#define GUI_BIDI_MAX_LEVEL 14
#endif
#define ON 0 /* Other Neutrals */
#define L 1 /* Left-to-Right */
#define R 2 /* Right-to-Left */
#define AN 3 /* Arabic Number */
#define EN 4 /* European Number */
#define AL 5 /* Right-to-Left Arabic */
#define NSM 6 /* Non-Spacing Mark */
#define CS 7 /* Common Number Separator */
#define ES 8 /* European Number Separator */
#define ET 9 /* European Number Terminator */
#define BN 10 /* Boundary Neutral */
#define S 11 /* Segment Separator */
#define WS 12 /* Whitespace */
#define B 13 /* Paragraph Separator */
#define RLO 14 /* Right-to-Left Override */
#define RLE 15 /* Right-to-Left Embedding */
#define LRO 16 /* Left-to-Right Override */
#define LRE 17 /* Left-to-Right Embedding */
#define PDF 18 /* Pop Directional Format */
#define N ON
#define GREATER_EVEN(i) (i & 1) ? i + 1 : i + 2
#define GREATER_ODD(i) (i & 1) ? i + 2 : i + 1
#define EMBEDDING_DIRECTION(Level) (Level & 1) ? R : L
/*********************************************************************
*
* Types
*
**********************************************************************
*/
typedef struct {
U16 Code;
U8 Type;
} TYPE;
typedef struct {
U16 Code;
U16 CodeM;
} PAIR;
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
/*********************************************************************
*
* _aTypes
*
* Purpose:
* The following table contains the types of all assigned
* Unicode characters.
*/
static const TYPE _aTypes[] = {
{0x0000 , BN }, /* <control> */
{0x0001 , BN }, /* <control> */
{0x0002 , BN }, /* <control> */
{0x0003 , BN }, /* <control> */
{0x0004 , BN }, /* <control> */
{0x0005 , BN }, /* <control> */
{0x0006 , BN }, /* <control> */
{0x0007 , BN }, /* <control> */
{0x0008 , BN }, /* <control> */
{0x0009 , S }, /* <control> */
{0x000A , B }, /* <control> */
{0x000B , S }, /* <control> */
{0x000C , WS }, /* <control> */
{0x000D , B }, /* <control> */
{0x000E , BN }, /* <control> */
{0x000F , BN }, /* <control> */
{0x0010 , BN }, /* <control> */
{0x0011 , BN }, /* <control> */
{0x0012 , BN }, /* <control> */
{0x0013 , BN }, /* <control> */
{0x0014 , BN }, /* <control> */
{0x0015 , BN }, /* <control> */
{0x0016 , BN }, /* <control> */
{0x0017 , BN }, /* <control> */
{0x0018 , BN }, /* <control> */
{0x0019 , BN }, /* <control> */
{0x001A , BN }, /* <control> */
{0x001B , BN }, /* <control> */
{0x001C , B }, /* <control> */
{0x001D , B }, /* <control> */
{0x001E , B }, /* <control> */
{0x001F , S }, /* <control> */
{0x0020 , WS }, /* SPACE */
{0x0021 , ON }, /* EXCLAMATION MARK */
{0x0022 , ON }, /* QUOTATION MARK */
{0x0023 , ET }, /* NUMBER SIGN */
{0x0024 , ET }, /* DOLLAR SIGN */
{0x0025 , ET }, /* PERCENT SIGN */
{0x0026 , ON }, /* AMPERSAND */
{0x0027 , ON }, /* APOSTROPHE */
{0x0028 , ON }, /* LEFT PARENTHESIS */
{0x0029 , ON }, /* RIGHT PARENTHESIS */
{0x002A , ON }, /* ASTERISK */
{0x002B , ES }, /* PLUS SIGN */
{0x002C , CS }, /* COMMA */
{0x002D , ES }, /* HYPHEN-MINUS */
{0x002E , CS }, /* FULL STOP */
{0x002F , CS }, /* SOLIDUS */
{0x0030 , EN }, /* DIGIT ZERO */
{0x0031 , EN }, /* DIGIT ONE */
{0x0032 , EN }, /* DIGIT TWO */
{0x0033 , EN }, /* DIGIT THREE */
{0x0034 , EN }, /* DIGIT FOUR */
{0x0035 , EN }, /* DIGIT FIVE */
{0x0036 , EN }, /* DIGIT SIX */
{0x0037 , EN }, /* DIGIT SEVEN */
{0x0038 , EN }, /* DIGIT EIGHT */
{0x0039 , EN }, /* DIGIT NINE */
{0x003A , CS }, /* COLON */
{0x003B , ON }, /* SEMICOLON */
{0x003C , ON }, /* LESS-THAN SIGN */
{0x003D , ON }, /* EQUALS SIGN */
{0x003E , ON }, /* GREATER-THAN SIGN */
{0x003F , ON }, /* QUESTION MARK */
{0x0040 , ON }, /* COMMERCIAL AT */
{0x0041 , L }, /* LATIN CAPITAL LETTER A */
{0x0042 , L }, /* LATIN CAPITAL LETTER B */
{0x0043 , L }, /* LATIN CAPITAL LETTER C */
{0x0044 , L }, /* LATIN CAPITAL LETTER D */
{0x0045 , L }, /* LATIN CAPITAL LETTER E */
{0x0046 , L }, /* LATIN CAPITAL LETTER F */
{0x0047 , L }, /* LATIN CAPITAL LETTER G */
{0x0048 , L }, /* LATIN CAPITAL LETTER H */
{0x0049 , L }, /* LATIN CAPITAL LETTER I */
{0x004A , L }, /* LATIN CAPITAL LETTER J */
{0x004B , L }, /* LATIN CAPITAL LETTER K */
{0x004C , L }, /* LATIN CAPITAL LETTER L */
{0x004D , L }, /* LATIN CAPITAL LETTER M */
{0x004E , L }, /* LATIN CAPITAL LETTER N */
{0x004F , L }, /* LATIN CAPITAL LETTER O */
{0x0050 , L }, /* LATIN CAPITAL LETTER P */
{0x0051 , L }, /* LATIN CAPITAL LETTER Q */
{0x0052 , L }, /* LATIN CAPITAL LETTER R */
{0x0053 , L }, /* LATIN CAPITAL LETTER S */
{0x0054 , L }, /* LATIN CAPITAL LETTER T */
{0x0055 , L }, /* LATIN CAPITAL LETTER U */
{0x0056 , L }, /* LATIN CAPITAL LETTER V */
{0x0057 , L }, /* LATIN CAPITAL LETTER W */
{0x0058 , L }, /* LATIN CAPITAL LETTER X */
{0x0059 , L }, /* LATIN CAPITAL LETTER Y */
{0x005A , L }, /* LATIN CAPITAL LETTER Z */
{0x005B , ON }, /* LEFT SQUARE BRACKET */
{0x005C , ON }, /* REVERSE SOLIDUS */
{0x005D , ON }, /* RIGHT SQUARE BRACKET */
{0x005E , ON }, /* CIRCUMFLEX ACCENT */
{0x005F , ON }, /* LOW LINE */
{0x0060 , ON }, /* GRAVE ACCENT */
{0x0061 , L }, /* LATIN SMALL LETTER A */
{0x0062 , L }, /* LATIN SMALL LETTER B */
{0x0063 , L }, /* LATIN SMALL LETTER C */
{0x0064 , L }, /* LATIN SMALL LETTER D */
{0x0065 , L }, /* LATIN SMALL LETTER E */
{0x0066 , L }, /* LATIN SMALL LETTER F */
{0x0067 , L }, /* LATIN SMALL LETTER G */
{0x0068 , L }, /* LATIN SMALL LETTER H */
{0x0069 , L }, /* LATIN SMALL LETTER I */
{0x006A , L }, /* LATIN SMALL LETTER J */
{0x006B , L }, /* LATIN SMALL LETTER K */
{0x006C , L }, /* LATIN SMALL LETTER L */
{0x006D , L }, /* LATIN SMALL LETTER M */
{0x006E , L }, /* LATIN SMALL LETTER N */
{0x006F , L }, /* LATIN SMALL LETTER O */
{0x0070 , L }, /* LATIN SMALL LETTER P */
{0x0071 , L }, /* LATIN SMALL LETTER Q */
{0x0072 , L }, /* LATIN SMALL LETTER R */
{0x0073 , L }, /* LATIN SMALL LETTER S */
{0x0074 , L }, /* LATIN SMALL LETTER T */
{0x0075 , L }, /* LATIN SMALL LETTER U */
{0x0076 , L }, /* LATIN SMALL LETTER V */
{0
评论0