Dekel language/encoding patch + a few fixes

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1096 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2000-10-10 12:36:36 +00:00
parent 71f8ac34a9
commit bd659b25fb
30 changed files with 706 additions and 554 deletions

View File

@ -1,3 +1,41 @@
2000-10-10 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* lib/Makefile.am (pkgdata_DATA): add encoding and languages
* src/tabular.h: add a few std:: qualifiers.
* src/encoding.C: add using directive.
* src/language.C: ditto.
* src/insets/insetquotes.C (Validate): use languages->lang()
instead of only language.
2000-10-07 Dekel Tsur <dekelts@tau.ac.il>
* lib/languages: New file.
* lib/encodings: New file.
* src/language.C (Languages): New class.
(read): New method. Reads the languages from the 'languages' file.
* src/encoding.C (Encodings): New class.
(read): New method. Reads the encodings from the 'encodings' file.
* src/lyx_main.C (init): Call to LyXSetStyle() after languages
initialization.
* src/bufferparams.h and a lot of files: Deleted the member language,
and renamed language_info to language
* src/buffer.C (makeLaTeXFile): Use babel() instead of lang()
* src/lyxfont.C (latexWriteStartChanges): ditto.
* src/paragraph.C (validate,TeXOnePar): ditto.
* src/lyxfont.C (update): Restored deleted code.
* src/frontends/xforms/FormDocument.C (build): Made the combox taller
2000-10-10 Angus Leeming <a.leeming@ic.ac.uk>
* src/BufferView_pimpl.C (buffer): cleaned up a little.
@ -28,6 +66,7 @@
*current_view->buffer(). This will change later, but this patch is way
big enough already!
>>>>>>> 1.592
2000-10-09 Juergen Vigna <jug@sad.it>
* src/text.C (GetRow): small fix.

View File

@ -26,7 +26,8 @@ LIBDISTFILES = $(BIND) $(CLIPART) $(DOCDIST) $(EXAMPLES) $(IMAGES) $(KBD) \
$(LAYOUT) $(TEMPL) $(UI) $(TEXSUPPORT) $(LYXSCRIPTS)
pkgdata_DATA = lyxrc.example CREDITS chkconfig.ltx lyxrc.defaults \
textclass.lst packages.lst external_templates
textclass.lst packages.lst external_templates \
encodings languages
LYXLIBDIRS = bind clipart doc examples images kbd layouts scripts \
templates tex ui

214
lib/encodings Normal file
View File

@ -0,0 +1,214 @@
Encoding iso8859-2 latin2
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f
80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f
90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f
00a0 0104 02d8 0141 00a4 013d 015a 00a7
00a8 0160 015e 0164 0179 00ad 017d 017b
00b0 0105 02db 0142 00b4 013e 015b 02c7
00b8 0161 015f 0165 017a 02dd 017e 017c
0154 00c1 00c2 0102 00c4 0139 0106 00c7
010c 00c9 0118 00cb 011a 00cd 00ce 010e
0110 0143 0147 00d3 00d4 0150 00d6 00d7
0158 016e 00da 0170 00dc 00dd 0162 00df
0155 00e1 00e2 0103 00e4 013a 0107 00e7
010d 00e9 0119 00eb 011b 00ed 00ee 010f
0111 0144 0148 00f3 00f4 0151 00f6 00f7
0159 016f 00fa 0171 00fc 00fd 0163 02d9
End
Encoding iso8859-3 latin3
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f
80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f
90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f
00a0 0126 02d8 00a3 00a4 ffff 0124 00a7
00a8 0130 015e 011e 0134 00ad ffff 017b
00b0 0127 00b2 00b3 00b4 00b5 0125 00b7
00b8 0131 015f 011f 0135 00bd ffff 017c
00c0 00c1 00c2 ffff 00c4 010a 0108 00c7
00c8 00c9 00ca 00cb 00cc 00cd 00ce 00cf
ffff 00d1 00d2 00d3 00d4 0120 00d6 00d7
011c 00d9 00da 00db 00dc 016c 015c 00df
00e0 00e1 00e2 ffff 00e4 010b 0109 00e7
00e8 00e9 00ea 00eb 00ec 00ed 00ee 00ef
ffff 00f1 00f2 00f3 00f4 0121 00f6 00f7
011d 00f9 00fa 00fb 00fc 016d 015d 02d9
End
Encoding iso8859-4 latin4
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f
80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f
90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f
00a0 0104 0138 0156 00a4 0128 013b 00a7
00a8 0160 0112 0122 0166 00ad 017d 00af
00b0 0105 02db 0157 00b4 0129 013c 02c7
00b8 0161 0113 0123 0167 014a 017e 014b
0100 00c1 00c2 00c3 00c4 00c5 00c6 012e
010c 00c9 0118 00cb 0116 00cd 00ce 012a
0110 0145 014c 0136 00d4 00d5 00d6 00d7
00d8 0172 00da 00db 00dc 0168 016a 00df
0101 00e1 00e2 00e3 00e4 00e5 00e6 012f
010d 00e9 0119 00eb 0117 00ed 00ee 012b
0111 0146 014d 0137 00f4 00f5 00f6 00f7
00f8 0173 00fa 00fb 00fc 0169 016b 02d9
End
Encoding iso8859-6 unknown
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
0660 0661 0662 0663 0664 0665 0666 0667
0668 0669 003a 003b 003c 003d 003e 061f
0040 fe80 fe81 fe83 fe85 fe87 fe89 fe8d
fe8f fe93 fe95 fe99 fe9d fea1 fea5 fea9
feab fead feaf feb1 feb5 feb9 febd fec1
fec5 fec9 fecd 005d 005c 005b 005e 005f
0640 fed1 fed5 fed9 fedd fee1 fee5 fee9
feed feef fef1 065b 065c 064d 064e 064f
0650 0651 0652 0073 0074 0075 fef5 fef7
fef9 fefb 007a 007b 007c 007d 007e 007f
80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f
fe71 0091 0092 fe77 fe79 fe7b fe7f fe7d
0098 0099 009a 009b 009c 009d 009e 009f
fe8c fe82 fe84 fe86 fe88 fe8e feaa feac
feae feb0 feee fef0 fe91 fe92 fe90 fe97
fe98 fe94 fe97 fe98 fe96 fe9b fe9c fe9a
fe9f fea0 fe9e fea3 fea4 fea2 fea7 fea8
fea6 feb3 feb4 feb2 feb7 feb8 feb6 febb
febc feba febf fec0 febe fec3 fec4 fec2
fec7 fec8 fec6 fecb fecc feca fecf fed0
fece fed3 fed4 fed2 fed7 fed8 fed6 fedb
fedc feda fedf fee0 fede fee3 fee4 fee2
fee7 fee8 fee6 feeb feec feea fef3 fef4
fef2 00f1 00f2 00f3 00f4 00f5 00f6 00f7
fe8b fe8a fef6 fefa fef8 fefc 00fe 00ff
End
Encoding iso8859-7 iso-8859-7
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f
80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f
90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f
00a0 0371 0372 00a3 ffff ffff 00a6 00a7
00a8 00a9 ffff 00ab 00ac 00ad ffff 2015
00b0 00b1 00b2 00b3 03f3 03f4 0386 00b7
0388 0389 038a 00bb 038c 00bd 038e 038f
0390 0391 0392 0393 0394 0395 0396 0397
0398 0399 039a 039b 039c 039d 039e 039f
03a0 03a1 ffff 03a3 03a4 03a5 03a6 03a7
03a8 03a9 03aa 03ab 03ac 03ad 03ae 03af
03b0 03b1 03b2 03b3 03b4 03b5 03b6 03b7
03b8 03b9 03ba 03bb 03bc 03bd 03be 03bf
03c0 03c1 03c2 03c3 03c4 03c5 03c6 03c7
03c8 03c9 03ca 03cb 03cc 03cd 03ce ffff
End
Encoding iso8859-9 latin5
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f
80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f
90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f
00a0 00a1 00a2 00a3 00a4 00a5 00a6 00a7
00a8 00a9 00aa 00ab 00ac 00ad 00ae 00af
00b0 00b1 00b2 00b3 00b4 00b5 00b6 00b7
00b8 00b9 00ba 00bb 00bc 00bd 00be 00bf
00c0 00c1 00c2 00c3 00c4 00c5 00c6 00c7
00c8 00c9 00ca 00cb 00cc 00cd 00ce 00cf
011e 00d1 00d2 00d3 00d4 00d5 00d6 00d7
00d8 00d9 00da 00db 00dc 0130 015e 00df
00e0 00e1 00e2 00e3 00e4 00e5 00e6 00e7
00e8 00e9 00ea 00eb 00ec 00ed 00ee 00ef
011f 00f1 00f2 00f3 00f4 00f5 00f6 00f7
00f8 00f9 00fa 00fb 00fc 0131 015f 00ff
End
Encoding cp1255 cp1255
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f
80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f
90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f
00a0 ffff 00a2 00a3 00a4 00a5 00a6 00a7
00a8 00a9 00d7 00ab 00ac 00ad 00ae 203e
00b0 00b1 00b2 00b3 00b4 00b5 00b6 00b7
00b8 00b9 00f7 00bb 00bc 00bd 00be 00bf
05b0 05b1 05b2 05b3 05b4 05b5 05b6 05b7
05b8 05b9 ffff 05bb 05bc 05bd 05be 05bf
05c0 05c1 05c2 05c3 05f0 05f1 05f2 05f3
05f4 ffff ffff ffff ffff ffff ffff ffff
05d0 05d1 05d2 05d3 05d4 05d5 05d6 05d7
05d8 05d9 05da 05db 05dc 05dd 05de 05df
05e0 05e1 05e2 05e3 05e4 05e5 05e6 05e7
05e8 05e9 05ea ffff ffff ffff ffff ffff
End
Encoding koi8 koi8-r
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f
2500 2502 250c 2510 2514 2518 251c 2524
252c 2534 253c 2580 2584 2588 258c 2590
2591 2592 2593 2320 25a0 2219 221a 2248
2264 2265 00a0 2321 00b0 00b2 00b7 00f7
2550 2551 2552 0451 2553 2554 2555 2556
2557 2558 2559 255a 255b 255c 255d 255e
255f 2560 2561 0401 2562 2563 2564 2565
2566 2567 2568 2569 256a 256b 256c 00a9
044e 0430 0431 0446 0434 0435 0444 0433
0445 0438 0439 043a 043b 043c 043d 043e
043f 044f 0440 0441 0442 0443 0436 0432
044c 044b 0437 0448 044d 0449 0447 044a
042e 0410 0411 0426 0414 0415 0424 0413
0425 0418 0419 041a 041b 041c 041d 041e
041f 042f 0420 0421 0422 0423 0416 0412
042c 042b 0417 0428 042d 0429 0427 042a
End

48
lib/languages Normal file
View File

@ -0,0 +1,48 @@
afrikaans afrikaans "Afrikaans" false iso8859-1 af_ZA
american american "American" false iso8859-1 en_US
arabic arabic "Arabic" true iso8859-6 ar_SA
austrian austrian "Austrian" false iso8859-1 de_AU
bahasa bahasa "Bahasa" false iso8859-1 in_ID
brazil brazil "Brazil" false iso8859-1 pt_BR
breton breton "Breton" false iso8859-1 br_FR
british british "British" false iso8859-1 en_GB
canadian canadian "Canadian" false iso8859-1 en_CA
canadien frenchb "French Canadian" false iso8859-1 fr_CA
catalan catalan "Catalan" false iso8859-1 ca_ES
croatian croatian "Croatian" false iso8859-2 hr
czech czech "Czech" false iso8859-2 cs_CZ
danish danish "Danish" false iso8859-1 da_DK
dutch dutch "Dutch" false iso8859-1 nl
english english "English" false iso8859-1 en
esperanto esperanto "Esperanto" false iso8859-3 eo
#and what country code should esperanto have?? (Garst)
estonian estonian "Estonian" false iso8859-4 et_EE
finnish finnish "Finnish" false iso8859-1 fi
frenchb frenchb "French" false iso8859-1 fr
french french "French (GUTenberg)" false iso8859-1 fr
galician galician "Galician" false iso8859-1 gl_ES
# There are two Galicia's one in Spain one in E.Europe. Because of
# the font encoding I am assuming this is the one in Spain. (Garst)
german german "German" false iso8859-1 de
greek greek "Greek" false iso8859-7 el_GR
hebrew hebrew "Hebrew" true cp1255 he_IL
#hungarian hungarian "Hungarian" false iso8859-2 ""
irish irish "Irish" false iso8859-1 ga_IE
italian italian "Italian" false iso8859-1 it
lsorbian lsorbian "Lsorbian" false iso8859-2 ""
# no ISO listing for lsorbian (Garst)
magyar magyar "Magyar" false iso8859-2 hu
norsk norsk "Norsk" false iso8859-1 no
polish polish "Polish" false iso8859-2 pl
portuges portuges "Portuges" false iso8859-1 pt
romanian romanian "Romanian" false iso8859-2 ro
russian russian "Russian" false koi8 ru
scottish scottish "Scottish" false iso8859-1 gd_GB
spanish spanish "Spanish" false iso8859-1 es
slovak slovak "Slovak" false iso8859-2 sk_SL
slovene slovene "Slovene" false iso8859-2 sl_SI
swedish swedish "Swedish" false iso8859-1 sv_SE
turkish turkish "Turkish" false iso8859-9 tr
usorbian usorbian "Usorbian" false iso8859-2 ""
# no ISO listing for usorbian (Garst)
welsh welsh "Welsh" false iso8859-1 cy_GB

View File

@ -114,6 +114,7 @@ $(top_srcdir)/src/ext_l10n.h: $(top_srcdir)/lib/layouts/*.layout $(top_srcdir)/l
awk '{printf "_(\"%s\");\n", $$0}' > $@
cat $(top_srcdir)/lib/layouts/*.layout $(top_srcdir)/lib/layouts/*.inc | grep -i -E "[ ]*style .+$$" | \
cut -d ' ' -f 2 | sort | uniq | awk '{printf "_(\"%s\");\n", $$0}' >> $@
awk -F '"' '$2 {printf "_(\"%s\");\n", $2}' < $(top_srcdir)/lib/languages >> $@
install: install-exec install-data
install-exec:

View File

@ -146,7 +146,7 @@ string const LaTeXFeatures::getPackages()
// makeidx.sty
if (makeidx) {
if (! tclass.provides(LyXTextClass::makeidx)
&& params.language != "french") // french provides
&& params.language->babel() != "french") // french provides
// \index !
packages += "\\usepackage{makeidx}\n";
packages += "\\makeindex\n";

View File

@ -283,9 +283,9 @@ PainterBase & Painter::text(int x, int y, char const * s, size_t ls,
font2.setShape(LyXFont::UP_SHAPE);
font = &font2;
#endif
encoding = &symbol_encoding;
encoding = encodings.symbol_encoding();
}
for (int i = 0; i < ls; ++i) {
for (size_t i = 0; i < ls; ++i) {
Uchar c = encoding->ucs(s[i]);
xs[i].byte1 = c >> 8;
xs[i].byte2 = c & 0xff;
@ -310,7 +310,7 @@ PainterBase & Painter::text(int x, int y, char const * s, size_t ls,
smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
char c;
int tmpx = x;
for(int i = 0; i < ls; ++i) {
for(size_t i = 0; i < ls; ++i) {
c = s[i];
if (islower(static_cast<unsigned char>(c))) {
c = toupper(c);

View File

@ -246,8 +246,8 @@ bool Buffer::readLyXformat2(LyXLex & lex, LyXParagraph * par)
bool the_end_read = false;
LyXParagraph * return_par = 0;
LyXFont font(LyXFont::ALL_INHERIT, params.language_info);
if (format < 2.16 && params.language == "hebrew")
LyXFont font(LyXFont::ALL_INHERIT, params.language);
if (format < 2.16 && params.language->lang() == "hebrew")
font.setLanguage(default_language);
// If we are inserting, we cheat and get a token in advance
@ -363,8 +363,8 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
par->footnotekind = footnotekind;
#endif
par->depth = depth;
font = LyXFont(LyXFont::ALL_INHERIT, params.language_info);
if (format < 2.16 && params.language == "hebrew")
font = LyXFont(LyXFont::ALL_INHERIT, params.language);
if (format < 2.16 && params.language->lang() == "hebrew")
font.setLanguage(default_language);
#ifndef NEW_INSETS
} else if (token == "\\end_float") {
@ -379,8 +379,8 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
pos = 0;
lex.EatLine();
par->layout = LYX_DUMMY_LAYOUT;
font = LyXFont(LyXFont::ALL_INHERIT, params.language_info);
if (format < 2.16 && params.language == "hebrew")
font = LyXFont(LyXFont::ALL_INHERIT, params.language);
if (format < 2.16 && params.language->lang() == "hebrew")
font.setLanguage(default_language);
} else if (token == "\\begin_float") {
int tmpret = lex.FindToken(string_footnotekinds);
@ -771,11 +771,11 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
} else if (token == "\\lang") {
lex.next();
string const tok = lex.GetString();
Languages::iterator lit = languages.find(tok);
if (lit != languages.end()) {
font.setLanguage(&(*lit).second);
Language const * lang = languages.getLanguage(tok);
if (lang) {
font.setLanguage(lang);
} else {
font.setLanguage(params.language_info);
font.setLanguage(params.language);
lex.printError("Unknown language `$$Token'");
}
} else if (token == "\\numeric") {
@ -1363,7 +1363,7 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
}
LyXFont font1 =
LyXFont(LyXFont::ALL_INHERIT, params.language_info);
LyXFont(LyXFont::ALL_INHERIT, params.language);
actcell = 0;
for (i = 0, actpos = 1; i < par->size(); ++i, ++actpos) {
if (!i && !footnoteflag && !noparbreak){
@ -1571,7 +1571,7 @@ string const Buffer::asciiParagraph(LyXParagraph const * par,
#endif
}
font1 = LyXFont(LyXFont::ALL_INHERIT, params.language_info);
font1 = LyXFont(LyXFont::ALL_INHERIT, params.language);
for (LyXParagraph::size_type i = 0; i < par->size(); ++i) {
if (!i && !footnoteflag && !noparbreak){
if (linelen > 0)
@ -1831,17 +1831,21 @@ void Buffer::makeLaTeXFile(string const & fname,
// language should be a parameter to \documentclass
bool use_babel = false;
if (params.language_info->lang() == "hebrew") // This seems necessary
if (params.language->babel() == "hebrew") // This seems necessary
features.UsedLanguages.insert(default_language);
if (params.language != "default" ||
#ifdef DO_USE_DEFAULT_LANGUAGE
if (params.language->lang() != "default" ||
!features.UsedLanguages.empty() ) {
#endif
use_babel = true;
for (LaTeXFeatures::LanguageList::const_iterator cit =
features.UsedLanguages.begin();
cit != features.UsedLanguages.end(); ++cit)
options += (*cit)->lang() + ",";
options += params.language_info->lang() + ',';
options += (*cit)->babel() + ",";
options += params.language->babel() + ',';
#ifdef DO_USE_DEFAULT_LANGUAGE
}
#endif
// the user-defined options
if (!params.options.empty()) {
@ -1873,7 +1877,7 @@ void Buffer::makeLaTeXFile(string const & fname,
if (params.inputenc == "auto") {
string const doc_encoding =
params.language_info->encoding()->LatexName();
params.language->encoding()->LatexName();
// Create a list with all the input encodings used
// in the document
@ -2141,9 +2145,13 @@ void Buffer::makeLaTeXFile(string const & fname,
texrow.newline();
} // only_body
lyxerr.debug() << "preamble finished, now the body." << endl;
if (!lyxrc.language_auto_begin && params.language != "default") {
#ifdef DO_USE_DEFAULT_LANGUAGE
if (!lyxrc.language_auto_begin && params.language->lang() != "default") {
#else
if (!lyxrc.language_auto_begin) {
#endif
ofs << subst(lyxrc.language_command_begin, "$$lang",
params.language)
params.language->babel())
<< endl;
texrow.newline();
}
@ -2154,9 +2162,13 @@ void Buffer::makeLaTeXFile(string const & fname,
ofs << endl;
texrow.newline();
if (!lyxrc.language_auto_end && params.language != "default") {
#ifdef DO_USE_DEFAULT_LANGUAGE
if (!lyxrc.language_auto_end && params.language->lang() != "default") {
#else
if (!lyxrc.language_auto_end) {
#endif
ofs << subst(lyxrc.language_command_end, "$$lang",
params.language)
params.language->babel())
<< endl;
texrow.newline();
}

View File

@ -38,6 +38,7 @@ class LyXRC;
class TeXErrors;
class LaTeXFeatures;
class auto_mem_buffer;
class Language;
///
struct DEPCLEAN {
@ -176,7 +177,7 @@ public:
bool nice, bool only_body = false);
/// returns the main language for the buffer (document)
string const GetLanguage() const {
Language const * GetLanguage() const {
return params.language;
}

View File

@ -50,8 +50,7 @@ BufferParams::BufferParams()
use_amsmath = false;
secnumdepth = 3;
tocdepth = 3;
language = default_language->lang();
language_info = default_language;
language = default_language;
fonts = "default";
inputenc = "auto";
graphicsDriver = "default";
@ -88,7 +87,7 @@ void BufferParams::writeFile(ostream & os) const
}
/* then the text parameters */
os << "\\language " << language
os << "\\language " << language->lang()
<< "\n\\inputencoding " << inputenc
<< "\n\\fontscheme " << fonts
<< "\n\\graphics " << graphicsDriver << '\n';
@ -202,21 +201,14 @@ void BufferParams::readLanguage(LyXLex & lex)
string tmptok = lex.GetString();
// check if tmptok is part of tex_babel in tex-defs.h
Languages::iterator lit = languages.find(tmptok);
if (lit != languages.end()) {
// found it
language = tmptok;
language_info = &(*lit).second;
} else {
// not found
language = default_language->lang();
language_info = default_language;
if (tmptok != "default") {
language = languages.getLanguage(tmptok);
if (!language) {
// Language tmptok was not found
language = default_language;
lyxerr << "Warning: language `"
<< tmptok << "' not recognized!\n"
<< " Setting language to `default'."
<< endl;
}
<< " Setting language to `" << language->lang()
<< "'." << endl;
}
}

View File

@ -174,9 +174,7 @@ public:
///
int tocdepth;
///
string language;
///
Language const * language_info;
Language const * language;
///
string inputenc;
///

View File

@ -92,9 +92,9 @@ void Number(BufferView * bv)
void Lang(BufferView * bv, string const & l)
{
LyXFont font(LyXFont::ALL_IGNORE);
Languages::iterator lit = languages.find(l);
if (lit != languages.end()) {
font.setLanguage(&(*lit).second);
Language const * lang = languages.getLanguage(l);
if (lang) {
font.setLanguage(lang);
ToggleAndShow(bv, font);
} else
WriteAlert(_("Error! unknown language"),l);

View File

@ -15,6 +15,11 @@
#endif
#include "encoding.h"
#include "debug.h"
using std::endl;
Encodings encodings;
static
Uchar tab_iso8859_1[256] = {
@ -36,231 +41,6 @@ Uchar tab_iso8859_1[256] = {
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
};
static
Uchar tab_iso8859_2[256] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
0x00a0, 0x0104, 0x02d8, 0x0141, 0x00a4, 0x013d, 0x015a, 0x00a7,
0x00a8, 0x0160, 0x015e, 0x0164, 0x0179, 0x00ad, 0x017d, 0x017b,
0x00b0, 0x0105, 0x02db, 0x0142, 0x00b4, 0x013e, 0x015b, 0x02c7,
0x00b8, 0x0161, 0x015f, 0x0165, 0x017a, 0x02dd, 0x017e, 0x017c,
0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7,
0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e,
0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7,
0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df,
0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7,
0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f,
0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7,
0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9
};
static
Uchar tab_iso8859_3[256] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
0x00a0, 0x0126, 0x02d8, 0x00a3, 0x00a4, 0xffff, 0x0124, 0x00a7,
0x00a8, 0x0130, 0x015e, 0x011e, 0x0134, 0x00ad, 0xffff, 0x017b,
0x00b0, 0x0127, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x0125, 0x00b7,
0x00b8, 0x0131, 0x015f, 0x011f, 0x0135, 0x00bd, 0xffff, 0x017c,
0x00c0, 0x00c1, 0x00c2, 0xffff, 0x00c4, 0x010a, 0x0108, 0x00c7,
0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
0xffff, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x0120, 0x00d6, 0x00d7,
0x011c, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x016c, 0x015c, 0x00df,
0x00e0, 0x00e1, 0x00e2, 0xffff, 0x00e4, 0x010b, 0x0109, 0x00e7,
0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
0xffff, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x0121, 0x00f6, 0x00f7,
0x011d, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x016d, 0x015d, 0x02d9,
};
static
Uchar tab_iso8859_4[256] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
0x00a0, 0x0104, 0x0138, 0x0156, 0x00a4, 0x0128, 0x013b, 0x00a7,
0x00a8, 0x0160, 0x0112, 0x0122, 0x0166, 0x00ad, 0x017d, 0x00af,
0x00b0, 0x0105, 0x02db, 0x0157, 0x00b4, 0x0129, 0x013c, 0x02c7,
0x00b8, 0x0161, 0x0113, 0x0123, 0x0167, 0x014a, 0x017e, 0x014b,
0x0100, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x012e,
0x010c, 0x00c9, 0x0118, 0x00cb, 0x0116, 0x00cd, 0x00ce, 0x012a,
0x0110, 0x0145, 0x014c, 0x0136, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
0x00d8, 0x0172, 0x00da, 0x00db, 0x00dc, 0x0168, 0x016a, 0x00df,
0x0101, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x012f,
0x010d, 0x00e9, 0x0119, 0x00eb, 0x0117, 0x00ed, 0x00ee, 0x012b,
0x0111, 0x0146, 0x014d, 0x0137, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x0169, 0x016b, 0x02d9
};
static
Uchar tab_iso8859_6_16[256] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667,
0x0668, 0x0669, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x061f,
0x0040, 0xfe80, 0xfe81, 0xfe83, 0xfe85, 0xfe87, 0xfe89, 0xfe8d,
0xfe8f, 0xfe93, 0xfe95, 0xfe99, 0xfe9d, 0xfea1, 0xfea5, 0xfea9,
0xfeab, 0xfead, 0xfeaf, 0xfeb1, 0xfeb5, 0xfeb9, 0xfebd, 0xfec1,
0xfec5, 0xfec9, 0xfecd, 0x005d, 0x005c, 0x005b, 0x005e, 0x005f,
0x0640, 0xfed1, 0xfed5, 0xfed9, 0xfedd, 0xfee1, 0xfee5, 0xfee9,
0xfeed, 0xfeef, 0xfef1, 0x065b, 0x065c, 0x064d, 0x064e, 0x064f,
0x0650, 0x0651, 0x0652, 0x0073, 0x0074, 0x0075, 0xfef5, 0xfef7,
0xfef9, 0xfefb, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0xfe71, 0x0091, 0x0092, 0xfe77, 0xfe79, 0xfe7b, 0xfe7f, 0xfe7d,
0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
0xfe8c, 0xfe82, 0xfe84, 0xfe86, 0xfe88, 0xfe8e, 0xfeaa, 0xfeac,
0xfeae, 0xfeb0, 0xfeee, 0xfef0, 0xfe91, 0xfe92, 0xfe90, 0xfe97,
0xfe98, 0xfe94, 0xfe97, 0xfe98, 0xfe96, 0xfe9b, 0xfe9c, 0xfe9a,
0xfe9f, 0xfea0, 0xfe9e, 0xfea3, 0xfea4, 0xfea2, 0xfea7, 0xfea8,
0xfea6, 0xfeb3, 0xfeb4, 0xfeb2, 0xfeb7, 0xfeb8, 0xfeb6, 0xfebb,
0xfebc, 0xfeba, 0xfebf, 0xfec0, 0xfebe, 0xfec3, 0xfec4, 0xfec2,
0xfec7, 0xfec8, 0xfec6, 0xfecb, 0xfecc, 0xfeca, 0xfecf, 0xfed0,
0xfece, 0xfed3, 0xfed4, 0xfed2, 0xfed7, 0xfed8, 0xfed6, 0xfedb,
0xfedc, 0xfeda, 0xfedf, 0xfee0, 0xfede, 0xfee3, 0xfee4, 0xfee2,
0xfee7, 0xfee8, 0xfee6, 0xfeeb, 0xfeec, 0xfeea, 0xfef3, 0xfef4,
0xfef2, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
0xfe8b, 0xfe8a, 0xfef6, 0xfefa, 0xfef8, 0xfefc, 0x00fe, 0x00ff
};
static
Uchar tab_iso8859_7[256] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
0x00a0, 0x0371, 0x0372, 0x00a3, 0xffff, 0xffff, 0x00a6, 0x00a7,
0x00a8, 0x00a9, 0xffff, 0x00ab, 0x00ac, 0x00ad, 0xffff, 0x2015,
0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x03f3, 0x03f4, 0x0386, 0x00b7,
0x0388, 0x0389, 0x038a, 0x00bb, 0x038c, 0x00bd, 0x038e, 0x038f,
0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f,
0x03a0, 0x03a1, 0xffff, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7,
0x03a8, 0x03a9, 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03ae, 0x03af,
0x03b0, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7,
0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf,
0x03c0, 0x03c1, 0x03c2, 0x03c3, 0x03c4, 0x03c5, 0x03c6, 0x03c7,
0x03c8, 0x03c9, 0x03ca, 0x03cb, 0x03cc, 0x03cd, 0x03ce, 0xffff
};
static
Uchar tab_iso8859_9[256] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
0x011e, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0130, 0x015e, 0x00df,
0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
0x011f, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0131, 0x015f, 0x00ff,
};
static
Uchar tab_cp1255[256] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
0x00a0, 0xffff, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
0x00a8, 0x00a9, 0x00d7, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x203e,
0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
0x00b8, 0x00b9, 0x00f7, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
0x05b0, 0x05b1, 0x05b2, 0x05b3, 0x05b4, 0x05b5, 0x05b6, 0x05b7,
0x05b8, 0x05b9, 0xffff, 0x05bb, 0x05bc, 0x05bd, 0x05be, 0x05bf,
0x05c0, 0x05c1, 0x05c2, 0x05c3, 0x05f0, 0x05f1, 0x05f2, 0x05f3,
0x05f4, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, 0x05d6, 0x05d7,
0x05d8, 0x05d9, 0x05da, 0x05db, 0x05dc, 0x05dd, 0x05de, 0x05df,
0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5, 0x05e6, 0x05e7,
0x05e8, 0x05e9, 0x05ea, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
};
static
Uchar tab_koi8[256] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
0x2500, 0x2502, 0x250c, 0x2510, 0x2514, 0x2518, 0x251c, 0x2524,
0x252c, 0x2534, 0x253c, 0x2580, 0x2584, 0x2588, 0x258c, 0x2590,
0x2591, 0x2592, 0x2593, 0x2320, 0x25a0, 0x2219, 0x221a, 0x2248,
0x2264, 0x2265, 0x00a0, 0x2321, 0x00b0, 0x00b2, 0x00b7, 0x00f7,
0x2550, 0x2551, 0x2552, 0x0451, 0x2553, 0x2554, 0x2555, 0x2556,
0x2557, 0x2558, 0x2559, 0x255a, 0x255b, 0x255c, 0x255d, 0x255e,
0x255f, 0x2560, 0x2561, 0x0401, 0x2562, 0x2563, 0x2564, 0x2565,
0x2566, 0x2567, 0x2568, 0x2569, 0x256a, 0x256b, 0x256c, 0x00a9,
0x044e, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433,
0x0445, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e,
0x043f, 0x044f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432,
0x044c, 0x044b, 0x0437, 0x0448, 0x044d, 0x0449, 0x0447, 0x044a,
0x042e, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413,
0x0425, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e,
0x041f, 0x042f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412,
0x042c, 0x042b, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a
};
#ifdef USE_UNICODE_FOR_SYMBOLS
static
Uchar tab_symbol[256] = {
@ -457,32 +237,15 @@ unsigned char arabic_table[63][2] = {
{0,0} // 0xff
};
Encoding iso8859_1("latin1",tab_iso8859_1);
Encoding iso8859_2("latin2",tab_iso8859_2);
Encoding iso8859_3("latin3",tab_iso8859_3);
Encoding iso8859_4("latin4",tab_iso8859_4);
Encoding iso8859_6("unknown",tab_iso8859_6_16);
Encoding iso8859_7("iso-8859-7",tab_iso8859_7);
Encoding iso8859_9("latin5",tab_iso8859_9);
Encoding cp1255("cp1255",tab_cp1255);
Encoding koi8("koi8-r",tab_koi8);
#ifdef USE_UNICODE_FOR_SYMBOLS
Encoding symbol_encoding("",tab_symbol);
#else
Encoding symbol_encoding("",tab_iso8859_1);
#endif
bool Encoding::IsComposeChar_hebrew(unsigned char c)
bool Encodings::IsComposeChar_hebrew(unsigned char c)
{
return c <= 0xd2 && c >= 0xc0 &&
c != 0xce && c != 0xd0;
}
bool Encoding::IsComposeChar_arabic(unsigned char c)
bool Encodings::IsComposeChar_arabic(unsigned char c)
{
return c >= 0xeb && c <= 0xf2;
}
@ -492,14 +255,14 @@ static
unsigned char const arabic_start = 0xc1;
bool Encoding::is_arabic(unsigned char c)
bool Encodings::is_arabic(unsigned char c)
{
return c >= arabic_start && arabic_table[c-arabic_start][0];
}
unsigned char Encoding::TransformChar(unsigned char c,
Encoding::Letter_Form form)
unsigned char Encodings::TransformChar(unsigned char c,
Encodings::Letter_Form form)
{
if (!is_arabic(c))
return c;
@ -509,3 +272,71 @@ unsigned char Encoding::TransformChar(unsigned char c,
else
return arabic_table[c-arabic_start][form >> 1];
}
Encoding const * Encodings::getEncoding(string const & encoding) const
{
EncodingList::const_iterator it = encodinglist.find(encoding);
if (it != encodinglist.end())
return &(*it).second;
else
return 0;
}
Encodings::Encodings()
{
encodinglist["iso8859-1"] = Encoding("iso8859-1", "latin1", tab_iso8859_1);
symbol_encoding_ =
#ifdef USE_UNICODE_FOR_SYMBOLS
Encoding("symbol", "", tab_symbol);
#else
Encoding("symbol", "", tab_iso8859_1);
#endif
}
void Encodings::read(string const & filename)
{
enum Encodingtags {
et_encoding = 1,
et_end,
et_last
};
struct keyword_item encodingtags[et_last - 1] = {
{ "encoding", et_encoding },
{ "end", et_end }
};
LyXLex lex(encodingtags, et_last - 1);
lex.setFile(filename);
while (lex.IsOK()) {
switch (lex.lex()) {
case et_encoding:
{
lex.next();
string name = lex.GetString();
lex.next();
string latexname = lex.GetString();
lyxerr[Debug::INIT] << "Reading encoding " << name << endl;
Uchar table[256];
for (unsigned int i = 0; i < 256; ++i) {
lex.next();
string tmp = lex.GetString();
table[i] = ::strtol(tmp.c_str(), 0 , 16);
}
encodinglist[name] = Encoding(name, latexname, table);
if (lex.lex() != et_end)
lex.printError("Encodings::read: "
"missing end");
break;
}
case et_end:
lex.printError("Encodings::read: Misplaced end");
break;
default:
lex.printError("Encodings::read: "
"Unknown tag: `$$Token'");
break;
}
}
}

View File

@ -25,6 +25,52 @@ typedef unsigned short int Uchar;
///
class Encoding {
public:
///
Encoding() {}
///
Encoding(string const & n, string const & l, Uchar const * e)
: Name_(n), LatexName_(l) {
for (int i = 0; i < 256; ++i)
encoding_table[i] = e[i];
}
///
string const & Name() const {
return Name_;
}
///
string const & LatexName() const {
return LatexName_;
}
///
Uchar ucs(unsigned char c) const {
return encoding_table[c];
}
private:
///
string Name_;
///
string LatexName_;
///
Uchar encoding_table[256];
};
extern Encoding symbol_encoding;
class Encodings {
public:
///
typedef std::map<string, Encoding> EncodingList;
///
Encodings();
///
void read(string const & filename);
///
Encoding const * getEncoding(string const & encoding) const;
///
Encoding const * symbol_encoding() {
return &symbol_encoding_;
}
///
enum Letter_Form {
///
@ -37,17 +83,6 @@ public:
FORM_MEDIAL
};
///
Encoding(string const & l, Uchar const * e)
: LatexName_(l) , encoding_table(e) {}
///
string const & LatexName() const {
return LatexName_;
}
///
Uchar ucs(unsigned char c) const {
return encoding_table[c];
}
///
static
bool IsComposeChar_hebrew(unsigned char c);
///
@ -59,32 +94,14 @@ public:
///
static
unsigned char TransformChar(unsigned char c, Letter_Form form);
private:
///
string LatexName_;
EncodingList encodinglist;
///
Uchar const * encoding_table;
Encoding symbol_encoding_;
};
///
extern Encoding iso8859_1;
///
extern Encoding iso8859_2;
///
extern Encoding iso8859_3;
///
extern Encoding iso8859_4;
///
extern Encoding iso8859_6;
///
extern Encoding iso8859_7;
///
extern Encoding iso8859_9;
///
extern Encoding cp1255;
///
extern Encoding koi8;
///
extern Encoding symbol_encoding;
extern Encodings encodings;
#endif

View File

@ -117,9 +117,9 @@ int lyxfont::width(char const * s, size_t n, LyXFont const & f)
font2.setShape(LyXFont::UP_SHAPE);
font = &font2;
#endif
encoding = &symbol_encoding;
encoding = encodings.symbol_encoding();
}
for (int i = 0; i < n; ++i) {
for (size_t i = 0; i < n; ++i) {
Uchar c = encoding->ucs(s[i]);
xs[i].byte1 = c >> 8;
xs[i].byte2 = c & 0xff;
@ -137,7 +137,7 @@ int lyxfont::width(char const * s, size_t n, LyXFont const & f)
char c;
LyXFont smallfont(f);
smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
for (int i = 0; i < n; ++i) {
for (size_t i = 0; i < n; ++i) {
c = s[i];
// when islower is a macro, the cast is needed (JMarc)
if (islower(static_cast<unsigned char>(c))) {

View File

@ -139,7 +139,7 @@ void FormDocument::build()
obj = class_->choice_doc_class;
fl_addto_form(class_->form);
combo_doc_class = new Combox(FL_COMBOX_DROPLIST);
combo_doc_class->add(obj->x, obj->y, obj->w, obj->h, 200);
combo_doc_class->add(obj->x, obj->y, obj->w, obj->h, 400);
combo_doc_class->shortcut("#C",1);
combo_doc_class->setcallback(ComboInputCB, this);
fl_end_form();
@ -197,7 +197,7 @@ void FormDocument::build()
obj = language_->choice_language;
fl_addto_form(language_->form);
combo_language = new Combox(FL_COMBOX_DROPLIST);
combo_language->add(obj->x, obj->y, obj->w, obj->h, 200);
combo_language->add(obj->x, obj->y, obj->w, obj->h, 400);
combo_language->shortcut("#L",1);
combo_language->setcallback(ComboInputCB, this);
fl_end_form();
@ -205,7 +205,7 @@ void FormDocument::build()
#ifdef DO_USE_DEFAULT_LANGUAGE
combo_language->addto("default");
#endif
for(Languages::iterator cit = languages.begin();
for(Languages::const_iterator cit = languages.begin();
cit != languages.end(); ++cit) {
combo_language->addto((*cit).second.lang().c_str());
}
@ -556,14 +556,10 @@ bool FormDocument::language_apply()
else
params.quotes_times = InsetQuotes::DoubleQ;
Language const * old_language = params.language_info;
params.language = combo_language->getline();
Languages::iterator lit = languages.find(params.language);
Language const * new_language;
if (lit != languages.end())
new_language = &(*lit).second;
else
Language const * old_language = params.language;
Language const * new_language =
languages.getLanguage(combo_language->getline());
if (!new_language)
new_language = default_language;
if (old_language != new_language
@ -573,7 +569,7 @@ bool FormDocument::language_apply()
if (old_language != new_language) {
redo = true;
}
params.language_info = new_language;
params.language = new_language;
params.inputenc = fl_get_choice_text(language_->choice_inputenc);
return redo;
@ -716,7 +712,7 @@ void FormDocument::language_update(BufferParams const & params)
if (!language_)
return;
combo_language->select_text(params.language.c_str());
combo_language->select_text(params.language->lang().c_str());
fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
fl_set_button(language_->radio_single, 0);

View File

@ -230,7 +230,7 @@ void InsetQuotes::Read(Buffer const *, LyXLex & lex)
int InsetQuotes::Latex(Buffer const * buf, ostream & os,
bool /*fragile*/, bool) const
{
string doclang = buf->GetLanguage();
string doclang = buf->GetLanguage()->lang();
int quoteind = quote_index[side][language];
string qstr;
@ -291,7 +291,7 @@ void InsetQuotes::Validate(LaTeXFeatures & features) const
{
char type = quote_char[quote_index[side][language]];
if (features.bufferParams().language == "default"
if (features.bufferParams().language->lang() == "default"
&& lyxrc.fontenc != "T1") {
if (times == InsetQuotes::SingleQ)
switch (type) {

View File

@ -19,128 +19,81 @@
#include "encoding.h"
#include "lyxrc.h"
#include "lyx_gui_misc.h"
#include "lyxlex.h"
#include "debug.h"
using std::endl;
Languages languages;
Language const * default_language;
Language ignore_lang("ignore", "ignore", "Ignore", false, 0, "ignore");
Language const * ignore_language = &ignore_lang;
///
class LangInit {
public:
///
LangInit() {
if (!init) initL();
init = true;
}
private:
///
void initL();
///
static bool init;
};
struct lang_item {
char const * lang;
char const * babel;
char const * display;
bool rtl;
Encoding const * encoding;
char const * code;
};
void LangInit::initL()
void Languages::setDefaults()
{
// Use this style of initialization to lower compilation times.
// Same method is used in LyXAction.C (Lgb)
languagelist["english"] = Language("english", "english", N_("English"),
false,
encodings.getEncoding("iso8859-1"),
"en");
default_language = &languagelist["english"];
}
void Languages::read(string const & filename)
{
LyXLex lex(0, 0);
lex.setFile(filename);
while (lex.IsOK()) {
string lang, babel, display, encoding_str, code;
bool rtl = false;
if (lex.next())
lang = lex.GetString();
else
break;
lyxerr[Debug::INIT] << "Reading language " << lang << endl;
if (lex.next())
babel = lex.GetString();
if (lex.next())
display = lex.GetString();
if (lex.next())
rtl = lex.GetBool();
if (lex.next())
encoding_str = lex.GetString();
if (lex.next())
code = lex.GetString();
Encoding const * encoding = encodings.getEncoding(encoding_str);
if (!encoding) {
encoding = encodings.getEncoding("iso8859-1");
lyxerr << "Unknown encoding " << encoding_str << endl;
}
languagelist[lang] = Language(lang, babel, display, rtl, encoding, code);
}
lang_item items[] = {
{ "afrikaans", "afrikaans", N_("Afrikaans"), false, &iso8859_1, "af_ZA" },
{ "american", "american", N_("American"), false, &iso8859_1, "en_US" },
{ "arabic", "arabic", N_("Arabic"), true, &iso8859_6, "ar_SA" },
{ "austrian", "austrian", N_("Austrian"), false, &iso8859_1, "de_AU" },
{ "bahasa", "bahasa", N_("Bahasa"), false, &iso8859_1, "in_ID" },
{ "brazil", "brazil", N_("Brazil"), false, &iso8859_1, "pt_BR" },
{ "breton", "breton", N_("Breton"), false, &iso8859_1, "br_FR" },
{ "british", "british", N_("British"), false, &iso8859_1, "en_GB" },
{ "canadian", "canadian", N_("Canadian"), false, &iso8859_1, "en_CA" },
{ "canadien", "frenchb", N_("French Canadian"), false, &iso8859_1, "fr_CA" },
{ "catalan", "catalan", N_("Catalan"), false, &iso8859_1, "ca_ES" },
{ "croatian", "croatian", N_("Croatian"), false, &iso8859_2, "hr" },
{ "czech", "czech", N_("Czech"), false, &iso8859_2, "cs_CZ" },
{ "danish", "danish", N_("Danish"), false, &iso8859_1, "da_DK" },
#ifdef DO_USE_DEFAULT_LANGUAGE
{ "default", "default", N_("Document wide language"), false, &iso8859_1, "" },
languagelist["default"] = Language("default", "default",
N_("Document wide language"),
false, &iso8859_1, "");
#endif
{ "dutch", "dutch", N_("Dutch"), false, &iso8859_1, "nl" },
{ "english", "english", N_("English"), false, &iso8859_1, "en" },
{ "esperanto", "esperanto", N_("Esperanto"), false, &iso8859_3, "eo" },
// and what country code should esperanto have?? (Garst)
{ "estonian", "estonian", N_("Estonian"), false, &iso8859_4, "et_EE" },
{ "finnish", "finnish", N_("Finnish"), false, &iso8859_1, "fi" },
{ "frenchb", "frenchb", N_("French"), false, &iso8859_1, "fr" },
{ "french", "french", N_("French (GUTenberg)"), false, &iso8859_1, "fr" },
{ "galician", "galician", N_("Galician"), false, &iso8859_1, "gl_ES" },
/*There are two Galicia's, one in Spain, one in E.Europe. Because of
the font encoding, I am assuming this is the one in Spain. (Garst)
*/
{ "german", "german", N_("German"), false, &iso8859_1, "de" },
{ "greek", "greek", N_("Greek"), false, &iso8859_7, "el_GR" },
{ "hebrew", "hebrew", N_("Hebrew"), true, &cp1255, "he_IL" },
/* According to Zrubecz Laszlo <zrubi@k2.jozsef.kando.hu>,
"magyar" is better. I kept it here in case we want
to provide aliasing of languages. (JMarc)
*/
//{ "hungarian", "hungarian", N_("Hungarian"), false, &iso8859_2, "" },
{ "irish", "irish", N_("Irish"), false, &iso8859_1, "ga_IE" },
{ "italian", "italian", N_("Italian"), false, &iso8859_1, "it" },
{ "lsorbian", "lsorbian", N_("Lsorbian"), false, &iso8859_2, "" },
// no ISO listing for lsorbian (Garst)
{ "magyar", "magyar", N_("Magyar"), false, &iso8859_2, "hu" },
{ "norsk", "norsk", N_("Norsk"), false, &iso8859_1, "no" },
{ "polish", "polish", N_("Polish"), false, &iso8859_2, "pl" },
{ "portuges", "portuges", N_("Portuges"), false, &iso8859_1, "pt" },
{ "romanian", "romanian", N_("Romanian"), false, &iso8859_2, "ro" },
{ "russian", "russian", N_("Russian"), false, &koi8, "ru" },
{ "scottish", "scottish", N_("Scottish"), false, &iso8859_1, "gd_GB" },
{ "spanish", "spanish", N_("Spanish"), false, &iso8859_1, "es" },
{ "slovak", "slovak", N_("Slovak"), false, &iso8859_2, "sk_SL" },
{ "slovene", "slovene", N_("Slovene"), false, &iso8859_2, "sl_SI" },
{ "swedish", "swedish", N_("Swedish"), false, &iso8859_1, "sv_SE" },
{ "turkish", "turkish", N_("Turkish"), false, &iso8859_9, "tr" },
{ "usorbian", "usorbian", N_("Usorbian"), false, &iso8859_2, "" },
// no ISO listing for usorbian (Garst)
{ "welsh", "welsh", N_("Welsh"), false, &iso8859_1, "cy_GB" },
{ 0, 0, 0, false, 0, 0 }
};
int i = 0;
while (items[i].lang) {
languages[items[i].lang] =
Language(items[i].lang, items[i].babel,
items[i].display, items[i].rtl,
items[i].encoding, items[i].code);
++i;
default_language = getLanguage(lyxrc.default_language);
if (!default_language) {
lyxerr << "Default language \"" << lyxrc.default_language
<< "\" not found!" << endl;
default_language = getLanguage("english");
if (!default_language)
default_language = &(*languagelist.begin()).second;
lyxerr << "Using \"" << default_language->lang()
<< "\" instead!" << endl;
}
#if 0
// This code does not make sense as it is run even before
// main() is invoked. (JMarc)
if (languages.find(lyxrc.default_language) == languages.end()) {
string l1 = _("Default language \"") + lyxrc.default_language +
_("\" not found!");
WriteAlert(l1.c_str(), _("Using \"english\" instead!"),"");
default_language = &languages["english"];
} else
default_language = &languages[lyxrc.default_language];
#else
default_language = &languages["english"];
#endif
}
static
LangInit langinit;
bool LangInit::init = false;
Language const * Languages::getLanguage(string const & language) const
{
const_iterator it = languagelist.find(language);
if (it != languagelist.end())
return &(*it).second;
else
return 0;
}

View File

@ -71,30 +71,36 @@ private:
string code_;
};
#if 0
///
bool operator==(Language const & l1, Language const & l2)
class Languages
{
return l1.lang == l2.lang
&& l1.display_ == l2.display_
&& l1.RightToLeft_ == l2.RightToLeft_
&& l1.encoding_ == l2.encoding_;
public:
///
typedef std::map<string, Language> LanguageList;
///
typedef LanguageList::const_iterator const_iterator;
///
void read(string const & filename);
///
void setDefaults();
///
Language const * getLanguage(string const & language) const;
///
const_iterator begin() const {
return languagelist.begin();
}
///
bool operator!=(Language const l1, Language const & l2)
{
return !(l1 == l2);
const_iterator end() const {
return languagelist.end();
}
#endif
///
typedef std::map<string, Language> Languages;
private:
///
LanguageList languagelist;
};
extern Languages languages;
///
extern Language const * default_language;
///
extern Language const *ignore_language;
#endif

View File

@ -736,9 +736,9 @@ LyXFont const UserFreeFont(BufferParams const & params)
if (choice == 1)
font.setLanguage(ignore_language);
else if (choice == 2)
font.setLanguage(params.language_info);
font.setLanguage(params.language);
else
font.setLanguage(&languages[combo_language2->getline()]);
font.setLanguage(languages.getLanguage(combo_language2->getline()));
return font;
}

View File

@ -329,7 +329,7 @@ void LyXGUI::create_forms()
// build up the combox entries
combo_language2->addto(_("No change"));
combo_language2->addto(_("Reset"));
for(Languages::iterator cit = languages.begin();
for(Languages::const_iterator cit = languages.begin();
cit != languages.end(); ++cit) {
#ifdef DO_USE_DEFAULT_LANGUAGE
if ((*cit).second.lang() != "default")

View File

@ -38,6 +38,7 @@
#include "MenuBackend.h"
#include "ToolbarDefaults.h"
#include "lyxlex.h"
#include "encoding.h"
using std::endl;
@ -365,13 +366,6 @@ void LyX::init(int */*argc*/, char **argv, bool gui)
// Check that user LyX directory is ok.
queryUserLyXDir(explicit_userdir);
//
// Load the layouts first
//
lyxerr[Debug::INIT] << "Reading layouts..." << endl;
LyXSetStyle();
//
// Shine up lyxrc defaults
//
@ -410,6 +404,15 @@ void LyX::init(int */*argc*/, char **argv, bool gui)
if (!ReadRcFile("preferences"))
ReadRcFile("lyxrc");
// Read encodings
ReadEncodingsFile("encodings");
// Read languages
ReadLangugesFile("languages");
// Load the layouts
lyxerr[Debug::INIT] << "Reading layouts..." << endl;
LyXSetStyle();
// Ensure that we have really read a bind file, so that LyX is
// usable.
if (!lyxrc.hasBindFile)
@ -612,6 +615,7 @@ void LyX::ReadUIFile(string const & name)
if (ui_path.empty()) {
lyxerr[Debug::INIT] << "Could not find " << name << endl;
menubackend.defaults();
return;
}
@ -646,6 +650,35 @@ void LyX::ReadUIFile(string const & name)
}
// Read the languages file `name'
void LyX::ReadLangugesFile(string const & name)
{
lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
string lang_path = LibFileSearch(string(), name);
if (lang_path.empty()) {
lyxerr[Debug::INIT] << "Could not find " << name << endl;
languages.setDefaults();
return;
}
languages.read(lang_path);
}
// Read the encodings file `name'
void LyX::ReadEncodingsFile(string const & name)
{
lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
string enc_path = LibFileSearch(string(), name);
if (enc_path.empty()) {
lyxerr[Debug::INIT] << "Could not find " << name << endl;
return;
}
encodings.read(enc_path);
}
// Set debugging level and report result to user
void setDebuggingLevel(string const & dbgLevel)
{

View File

@ -74,6 +74,10 @@ private:
bool ReadRcFile(string const & name);
/// Read the ui file `name'
void ReadUIFile(string const & name);
/// Read the languages file `name'
void ReadLangugesFile(string const & name);
/// Read the encodings file `name'
void ReadEncodingsFile(string const & name);
///
bool easyParse(int * argc, char * argv[]);
};

View File

@ -292,6 +292,9 @@ void LyXFont::update(LyXFont const & newfont,
setNumber(setMisc(newfont.number(), number()));
if (newfont.language() == language() && toggleall)
if (language() == document_language)
setLanguage(default_language);
else
setLanguage(document_language);
else if (newfont.language() != ignore_language)
setLanguage(newfont.language());
@ -404,12 +407,11 @@ string const LyXFont::stateText(BufferParams * params) const
ost << _("Latex ") << _(GUIMiscNames[latex()]) << ", ";
if (bits == inherit)
ost << _("Default") << ", ";
if (!params || (language() != params->language_info))
if (!params || (language() != params->language))
ost << _("Language: ") << _(language()->display().c_str()) << ", ";
if (number() != OFF)
ost << _(" Number ") << _(GUIMiscNames[number()]);
string buf(ost.str().c_str());
buf = strip(buf, ' ');
buf = strip(buf, ',');
@ -676,7 +678,8 @@ int LyXFont::latexWriteStartChanges(ostream & os, LyXFont const & base,
int count = 0;
bool env = false;
if (language() != base.language() && language() != prev.language()) {
if (language()->babel() != base.language()->babel() &&
language()->babel() != prev.language()->babel()) {
if (isRightToLeft() != prev.isRightToLeft()) {
if (isRightToLeft()) {
os << "\\R{";
@ -688,7 +691,7 @@ int LyXFont::latexWriteStartChanges(ostream & os, LyXFont const & base,
} else {
string tmp = '{' +
subst(lyxrc.language_command_begin,
"$$lang", language()->lang());
"$$lang", language()->babel());
os << tmp;
count += tmp.length();
}

View File

@ -242,7 +242,7 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os,
if (bibkey)
bibkey->Write(buf, os);
LyXFont font1(LyXFont::ALL_INHERIT, params.language_info);
LyXFont font1(LyXFont::ALL_INHERIT, params.language);
int column = 0;
for (size_type i = 0; i < size(); ++i) {
@ -342,7 +342,7 @@ void LyXParagraph::validate(LaTeXFeatures & features) const
features.layout[GetLayout()] = true;
// then the fonts
Language const * doc_language = params.language_info;
Language const * doc_language = params.language;
for (FontList::const_iterator cit = fontlist.begin();
cit != fontlist.end(); ++cit) {
@ -368,10 +368,10 @@ void LyXParagraph::validate(LaTeXFeatures & features) const
}
Language const * language = (*cit).font.language();
if (language != doc_language) {
if (language->babel() != doc_language->babel()) {
features.UsedLanguages.insert(language);
lyxerr[Debug::LATEX] << "Found language "
<< language->lang() << endl;
<< language->babel() << endl;
}
}
@ -2262,12 +2262,13 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf,
}
Language const * language = getParLanguage(bparams);
Language const * doc_language = bparams.language_info;
Language const * doc_language = bparams.language;
Language const * previous_language = previous
? previous->getParLanguage(bparams) : doc_language;
if (language != doc_language && language != previous_language) {
if (language->babel() != doc_language->babel() &&
language->babel() != previous_language->babel()) {
os << subst(lyxrc.language_command_begin, "$$lang",
language->lang())
language->babel())
<< endl;
texrow.newline();
}
@ -2375,15 +2376,15 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf,
os << "{\\" << font.latexSize() << " \\par}";
}
if (language != doc_language &&
if (language->babel() != doc_language->babel() &&
(!par
#ifndef NEW_INSETS
|| (footnoteflag != NO_FOOTNOTE && par->footnoteflag != footnoteflag)
#endif
|| par->getParLanguage(bparams) != language)) {
|| par->getParLanguage(bparams)->babel() != language->babel())) {
os << endl
<< subst(lyxrc.language_command_end, "$$lang",
doc_language->lang());
doc_language->babel());
}
switch (style.latextype) {
@ -2547,7 +2548,7 @@ bool LyXParagraph::SimpleTeXOnePar(Buffer const * buf,
case LYX_ALIGN_SPECIAL:
break;
case LYX_ALIGN_LEFT:
if (getParLanguage(bparams)->lang() != "hebrew") {
if (getParLanguage(bparams)->babel() != "hebrew") {
os << "\\raggedright ";
column+= 13;
} else {
@ -2556,7 +2557,7 @@ bool LyXParagraph::SimpleTeXOnePar(Buffer const * buf,
}
break;
case LYX_ALIGN_RIGHT:
if (getParLanguage(bparams)->lang() != "hebrew") {
if (getParLanguage(bparams)->babel() != "hebrew") {
os << "\\raggedleft ";
column+= 12;
} else {
@ -3866,15 +3867,19 @@ LyXParagraph::getParLanguage(BufferParams const & bparams) const
else
#endif
if (size() > 0) {
#ifdef DO_USE_DEFAULT_LANGUAGE
Language const * lang = GetFirstFontSettings().language();
if (lang->lang() == default_language->lang())
return bparams.language_info;
if (lang->lang() == "default")
return bparams.language;
return lang;
#else
return GetFirstFontSettings().language();
#endif
} else if (previous)
return previous->getParLanguage(bparams);
return bparams.language_info;
else
return bparams.language;
}
@ -3900,7 +3905,7 @@ void LyXParagraph::ChangeLanguage(BufferParams const & bparams,
bool LyXParagraph::isMultiLingual(BufferParams const & bparams)
{
Language const * doc_language = bparams.language_info;
Language const * doc_language = bparams.language;
for (FontList::const_iterator cit = fontlist.begin();
cit != fontlist.end(); ++cit)
if ((*cit).font.language() != doc_language)

View File

@ -202,9 +202,9 @@ void LyXScreen::ShowCursor(LyXText const * text)
if (!cursor_visible) {
Cursor_Shape shape = BAR_SHAPE;
if (text->real_current_font.language() !=
owner.owner()->buffer()->params.language_info
owner.owner()->buffer()->params.language
|| text->real_current_font.isVisibleRightToLeft()
!= owner.owner()->buffer()->params.language_info->RightToLeft())
!= owner.owner()->buffer()->params.language->RightToLeft())
shape = (text->real_current_font.isVisibleRightToLeft())
? REVERSED_L_SHAPE : L_SHAPE;
ShowManualCursor(text, text->cursor.x(), text->cursor.y(),

View File

@ -395,7 +395,7 @@ void init_spell_checker(BufferParams const & params, string const & lang)
if (lyxrc.isp_use_input_encoding &&
params.inputenc != "default") {
string enc = (params.inputenc == "auto")
? params.language_info->encoding()->LatexName()
? params.language->encoding()->LatexName()
: params.inputenc;
string::size_type n = enc.length();
tmp = new char[3];
@ -806,20 +806,18 @@ bool RunSpellChecker(BufferView * bv)
#ifdef USE_PSPELL
string tmp = (lyxrc.isp_use_alt_lang) ?
lyxrc.isp_alt_lang : bv->buffer()->params.language_info->code();
lyxrc.isp_alt_lang : bv->buffer()->params.language->code();
#else
string tmp = (lyxrc.isp_use_alt_lang) ?
lyxrc.isp_alt_lang : bv->buffer()->GetLanguage();
lyxrc.isp_alt_lang : bv->buffer()->params.language->lang();
#endif
#warning This is not good we should find a way to identify a rtl-language in a more general way. Please have a look Dekel! (Jug)
// For now I'll change this to a bit more general solution but
// Please comment on this if you don't like it. We probaly need
// anoter flag something like lyxrc.isp_use_alt_lang_rtl (true/false)!
bool rtl;
if (lyxrc.isp_use_alt_lang)
rtl = (tmp == "hebrew" || tmp == "arabic");
else
rtl = bv->buffer()->params.language_info->RightToLeft();
bool rtl = false;
if (lyxrc.isp_use_alt_lang) {
Language const * lang = languages.getLanguage(tmp);
if (lang)
rtl = lang->RightToLeft();
} else
rtl = bv->buffer()->params.language->RightToLeft();
int oldval = 0; /* used for updating slider only when needed */
float newval = 0.0;

View File

@ -283,13 +283,13 @@ public:
// helper function for Latex returns number of newlines
///
int AsciiTopHLine(std::ostream &, int row,
vector<unsigned int> const &) const;
std::vector<unsigned int> const &) const;
///
int AsciiBottomHLine(std::ostream &, int row,
vector<unsigned int> const &) const;
std::vector<unsigned int> const &) const;
///
int AsciiPrintCell(Buffer const *, std::ostream &, int cell, int row,
int column, vector<unsigned int> const &) const;
int column, std::vector<unsigned int> const &) const;
///
int Ascii(Buffer const *, std::ostream &) const;
///

View File

@ -57,7 +57,7 @@ int LyXText::workWidth(BufferView * bview) const
unsigned char LyXText::TransformChar(unsigned char c, LyXParagraph * par,
LyXParagraph::size_type pos) const
{
if (!Encoding::is_arabic(c))
if (!Encodings::is_arabic(c))
if (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 && isdigit(c))
return c + (0xb0 - '0');
else
@ -66,21 +66,21 @@ unsigned char LyXText::TransformChar(unsigned char c, LyXParagraph * par,
unsigned char prev_char = pos > 0 ? par->GetChar(pos-1) : ' ';
unsigned char next_char = ' ';
for (LyXParagraph::size_type i = pos+1; i < par->Last(); ++i)
if (!Encoding::IsComposeChar_arabic(par->GetChar(i))) {
if (!Encodings::IsComposeChar_arabic(par->GetChar(i))) {
next_char = par->GetChar(i);
break;
}
if (Encoding::is_arabic(next_char)) {
if (Encoding::is_arabic(prev_char))
return Encoding::TransformChar(c, Encoding::FORM_MEDIAL);
if (Encodings::is_arabic(next_char)) {
if (Encodings::is_arabic(prev_char))
return Encodings::TransformChar(c, Encodings::FORM_MEDIAL);
else
return Encoding::TransformChar(c, Encoding::FORM_INITIAL);
return Encodings::TransformChar(c, Encodings::FORM_INITIAL);
} else {
if (Encoding::is_arabic(prev_char))
return Encoding::TransformChar(c, Encoding::FORM_FINAL);
if (Encodings::is_arabic(prev_char))
return Encodings::TransformChar(c, Encodings::FORM_FINAL);
else
return Encoding::TransformChar(c, Encoding::FORM_ISOLATED);
return Encodings::TransformChar(c, Encodings::FORM_ISOLATED);
}
}
@ -128,12 +128,12 @@ int LyXText::SingleWidth(BufferView * bview, LyXParagraph * par,
if (font.language()->lang() == "arabic" &&
(lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
lyxrc.font_norm_type == LyXRC::ISO_10646_1))
if (Encoding::IsComposeChar_arabic(c))
if (Encodings::IsComposeChar_arabic(c))
return 0;
else
c = TransformChar(c, par, pos);
else if (font.language()->lang() == "hebrew" &&
Encoding::IsComposeChar_hebrew(c))
Encodings::IsComposeChar_hebrew(c))
return 0;
}
return lyxfont::width(c, font);
@ -512,7 +512,7 @@ void LyXText::draw(BufferView * bview, Row const * row,
++vpos;
if (lyxrc.mark_foreign_language &&
font.language() != bview->buffer()->params.language_info) {
font.language() != bview->buffer()->params.language) {
int y = offset + row->height() - 1;
pain.line(int(tmpx), y, int(x), y,
LColor::language);
@ -541,12 +541,12 @@ void LyXText::draw(BufferView * bview, Row const * row,
LyXParagraph::size_type last = RowLastPrintable(row);
if (font.language()->lang() == "hebrew") {
if (Encoding::IsComposeChar_hebrew(c)) {
if (Encodings::IsComposeChar_hebrew(c)) {
int width = lyxfont::width(c, font2);
int dx = 0;
for (LyXParagraph::size_type i = pos-1; i >= 0; --i) {
c = row->par()->GetChar(i);
if (!Encoding::IsComposeChar_hebrew(c)) {
if (!Encodings::IsComposeChar_hebrew(c)) {
if (IsPrintableNonspace(c)) {
int width2 = SingleWidth(bview, row->par(), i, c);
dx = (c == 'ø' || c == 'ã') // dalet / resh
@ -562,7 +562,7 @@ void LyXText::draw(BufferView * bview, Row const * row,
while (vpos <= last &&
(pos = vis2log(vpos)) >= 0
&& IsPrintableNonspace(c = row->par()->GetChar(pos))
&& !Encoding::IsComposeChar_hebrew(c)
&& !Encodings::IsComposeChar_hebrew(c)
&& font2 == GetFont(bview->buffer(), row->par(), pos)) {
textstring += c;
++vpos;
@ -575,14 +575,14 @@ void LyXText::draw(BufferView * bview, Row const * row,
} else if (font.language()->lang() == "arabic" &&
(lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
lyxrc.font_norm_type == LyXRC::ISO_10646_1)) {
if (Encoding::IsComposeChar_arabic(c)) {
if (Encodings::IsComposeChar_arabic(c)) {
c = TransformChar(c, row->par(), pos);
textstring = c;
int width = lyxfont::width(c, font2);
int dx = 0;
for (LyXParagraph::size_type i = pos-1; i >= 0; --i) {
c = row->par()->GetChar(i);
if (!Encoding::IsComposeChar_arabic(c)) {
if (!Encodings::IsComposeChar_arabic(c)) {
if (IsPrintableNonspace(c)) {
int width2 = SingleWidth(bview, row->par(), i, c);
dx = (width2 - width) / 2;
@ -598,7 +598,7 @@ void LyXText::draw(BufferView * bview, Row const * row,
while (vpos <= last &&
(pos = vis2log(vpos)) >= 0
&& IsPrintableNonspace(c = row->par()->GetChar(pos))
&& !Encoding::IsComposeChar_arabic(c)
&& !Encodings::IsComposeChar_arabic(c)
&& font2 == GetFont(bview->buffer(), row->par(), pos)) {
c = TransformChar(c, row->par(), pos);
textstring += c;
@ -623,7 +623,7 @@ void LyXText::draw(BufferView * bview, Row const * row,
}
if (lyxrc.mark_foreign_language &&
font.language() != bview->buffer()->params.language_info) {
font.language() != bview->buffer()->params.language) {
int y = offset + row->height() - 1;
pain.line(int(tmpx), y, int(x), y,
LColor::language);

View File

@ -870,7 +870,7 @@ void LyXText::SetFont(BufferView * bview, LyXFont const & font, bool toggleall)
layoutfont = GetFont(bview->buffer(), cursor.par(),-1);
// Update current font
real_current_font.update(font,
bview->buffer()->params.language_info,
bview->buffer()->params.language,
toggleall);
// Reduce to implicit settings
@ -914,7 +914,7 @@ void LyXText::SetFont(BufferView * bview, LyXFont const & font, bool toggleall)
LyXFont newfont = GetFont(bview->buffer(),
cursor.par(), cursor.pos());
newfont.update(font,
bview->buffer()->params.language_info,
bview->buffer()->params.language,
toggleall);
SetCharFont(bview->buffer(),
cursor.par(), cursor.pos(), newfont);