Menu

[7c54b3]: / windows / src / joe / win / i18n.c  Maximize  Restore  History

Download this file

160 lines (128 with data), 3.5 kB

  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
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
* This file is part of Joe's Own Editor for Windows.
* Copyright (c) 2014 John J. Jordan.
*
* Joe's Own Editor for Windows is free software: you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* Joe's Own Editor for Windows is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Joe's Own Editor for Windows. If not, see
* <http://www.gnu.org/licenses/>.
*/
/*
** Replacement for i18n.c in the JOE source. Windows knows the character classes
** and purportedly these functions run quicker than a manual less-than/greater-than
** approach. More importantly, we don't need to store tables for everything.
*/
#include <wchar.h>
#include "types.h"
#ifdef NO
int joe_iswupper(struct charmap *foo, int c)
{
return iswupper((wint_t)c);
}
int joe_iswlower(struct charmap *foo, int c)
{
return iswlower((wint_t)c);
}
int joe_iswalpha(struct charmap *foo, int c)
{
return iswalpha((wint_t)c);
}
int joe_iswalpha_(struct charmap *foo, int c)
{
return (c == 0x5F) || iswalpha((wint_t)c);
}
int joe_iswalnum_(struct charmap *foo, int c)
{
return (c == 0x5F) || iswalnum((wint_t)c);
}
int joe_iswdigit(struct charmap *foo, int c)
{
return iswdigit((wint_t)c);
}
int joe_iswspace(struct charmap *foo, int c)
{
return iswspace((wint_t)c);
}
int joe_iswctrl(struct charmap *foo, int c)
{
return iswcntrl((wint_t)c);
}
int joe_iswpunct(struct charmap *foo, int c)
{
return iswpunct((wint_t)c);
}
int joe_iswgraph(struct charmap *foo, int c)
{
return iswgraph((wint_t)c);
}
int joe_iswprint(struct charmap *foo, int c)
{
return iswprint((wint_t)c);
}
int joe_iswxdigit(struct charmap *foo, int c)
{
return iswxdigit((wint_t)c);
}
int joe_iswblank(struct charmap *foo, int c)
{
// Don't know what this maps to in Windows, so just use the
// intervals from i18n.c
return c >= 0x2000
? ((c <= 0x200B && c != 0x2007) || c == 0x205F || c == 0x3000)
: (c == 0x0009 || c == 0x0020 || c == 0x1680);
}
int joe_towupper(struct charmap *foo, int c)
{
return towupper((wint_t)c);
}
int joe_towlower(struct charmap *foo, int c)
{
return towlower((wint_t)c);
}
#endif
int unictrl(int ucs)
{
/* Control characters are one column wide in JOE */
if (ucs < 32 || ucs == 0x7F)
return 1;
if (ucs >= 0x80 && ucs <= 0x9F)
return 4;
/* More control characters... */
if (ucs>=0x200b && ucs<=0x206f) {
if (ucs<=0x200f) return 6;
if (ucs>=0x2028 && ucs<=0x202E) return 6;
if (ucs>=0x2060 && ucs<=0x2063) return 6;
if (ucs>=0x206a) return 6;
}
/* More control characters... */
if (ucs>=0xFDD0 && ucs<=0xFDEF)
return 6;
if (ucs==0xFEFF)
return 6;
if (ucs>=0xFFF9 && ucs<=0xFFFB)
return 6;
if (ucs>=0xFFFE && ucs<=0xFFFF)
return 6;
return 0;
}
int joe_wcwidth(int wide, int ucs)
{
/* Use common wcwidth */
int wcwidth(int);
int control;
if (!locale_map->type || !wide)
{
return 1;
}
control = unictrl(ucs);
return control ? control : wcwidth(ucs);
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.