2
/******************************************************************************
4
* DESCRIPTION: Initialization of the X11 window manager
5
* COPYRIGHT : (C) 1999 Joris van der Hoeven
6
*******************************************************************************
7
* This software falls under the GNU general public license and comes WITHOUT
8
* ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
9
* If you don't have this file, write to the Free Software Foundation, Inc.,
10
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
11
******************************************************************************/
13
#include "X11/x_window.hpp"
14
#include "language.hpp"
16
#include "analyze.hpp"
17
#include "dictionary.hpp"
18
#include "iterator.hpp"
19
#include "message.hpp"
22
x_gui_rep* the_gui= NULL;
23
extern hashmap<Window,pointer> Window_to_window;
25
/******************************************************************************
27
******************************************************************************/
29
bool true_color= false;
30
bool reverse_colors= false;
32
color black, white, red, green, blue;
33
color yellow, magenta, orange, brown, pink;
34
color light_grey, grey, dark_grey;
36
static int CSCALES= 4;
37
static int CFACTOR= 5;
38
static int GREYS = 16;
39
static int CTOTAL = (CFACTOR*CFACTOR*CFACTOR+GREYS+1);
42
x_alloc_color (int r, int g, int b) {
44
int m= min (r, min (g, b));
45
int M= max (r, max (g, b));
46
int t= (r + g + b) / 3;
51
double lambda1= max (((double) (t - m)) / t,
52
((double) (M - t)) / (65535 - t));
53
double lambda2= max (((double) (t - m)) / tt,
54
((double) (M - t)) / (65535 - tt));
55
mu= lambda1 / lambda2;
57
r= (int) (tt + mu * (r - t) + 0.5);
58
g= (int) (tt + mu * (g - t) + 0.5);
59
b= (int) (tt + mu * (b - t) + 0.5);
62
return (r << 16) + (g << 8) + b;
68
if (!XAllocColor (the_gui->dpy, the_gui->cols, &col))
69
cerr << "Warning: can't allocate color\n";
75
if (true_color) return;
78
the_gui->cmap= new color [CTOTAL];
80
for (i=0; i<=GREYS; i++)
82
x_alloc_color ((i*65535)/GREYS, (i*65535)/GREYS, (i*65535)/GREYS);
84
for (r=0; r<=CSCALES; r++)
85
for (g=0; g<=CSCALES; g++)
86
for (b=0; b<=CSCALES; b++) {
87
i= r*CFACTOR*CFACTOR+ g*CFACTOR+ b+ GREYS+ 1;
88
the_gui->cmap[i]= x_alloc_color ((r*65535)/CSCALES,
95
rgb_color (int r, int g, int b) {
96
if (true_color) return (r << 16) + (g << 8) + b;
97
else if ((r==g) && (g==b)) return (r*GREYS+ 128)/255;
99
r= (r*CSCALES+ 128)/255;
100
g= (g*CSCALES+ 128)/255;
101
b= (b*CSCALES+ 128)/255;
102
return r*CFACTOR*CFACTOR+ g*CFACTOR+ b+ GREYS+ 1;
107
get_rgb_color (color col, int& r, int& g, int& b) {
109
r= (col >> 16) & 255;
110
g= (col >> 8 ) & 255;
113
else if (col <= GREYS) {
122
gg = (col/CFACTOR) % CFACTOR;
123
rr = (col/(CFACTOR*CFACTOR)) % CFACTOR;
124
r = (rr*255)/CSCALES;
125
g = (gg*255)/CSCALES;
126
b = (bb*255)/CSCALES;
131
named_color (string s) {
132
if ((N(s) == 4) && (s[0]=='#')) {
133
int r= 17 * from_hexadecimal (s (1, 2));
134
int g= 17 * from_hexadecimal (s (2, 3));
135
int b= 17 * from_hexadecimal (s (3, 4));
136
return rgb_color (r, g, b);
138
if ((N(s) == 7) && (s[0]=='#')) {
139
int r= from_hexadecimal (s (1, 3));
140
int g= from_hexadecimal (s (3, 5));
141
int b= from_hexadecimal (s (5, 7));
142
return rgb_color (r, g, b);
144
int pastel= (the_gui->depth>=16? 223: 191);
145
if (s == "black") return black;
146
if (s == "white") return white;
147
if (s == "grey") return grey;
148
if (s == "red") return red;
149
if (s == "blue") return blue;
150
if (s == "yellow") return yellow;
151
if (s == "green") return green;
152
if (s == "magenta") return magenta;
153
if (s == "cyan") return rgb_color (0, 255, 255);
154
if (s == "orange") return orange;
155
if (s == "brown") return brown;
156
if (s == "pink") return pink;
157
if (s == "broken white") return rgb_color (255, 255, pastel);
158
if (s == "light grey") return light_grey;
159
if (s == "dark grey") return dark_grey;
160
if (s == "dark red") return rgb_color (128, 0, 0);
161
if (s == "dark blue") return rgb_color (0, 0, 128);
162
if (s == "dark yellow") return rgb_color (128, 128, 0);
163
if (s == "dark green") return rgb_color (0, 128, 0);
164
if (s == "dark magenta") return rgb_color (128, 0, 128);
165
if (s == "dark cyan") return rgb_color (0, 128, 128);
166
if (s == "dark orange") return rgb_color (128, 64, 0);
167
if (s == "dark brown") return rgb_color (64, 16, 0);
168
if (s == "pastel grey") return rgb_color (pastel, pastel, pastel);
169
if (s == "pastel red") return rgb_color (255, pastel, pastel);
170
if (s == "pastel blue") return rgb_color (pastel, pastel, 255);
171
if (s == "pastel yellow") return rgb_color (255, 255, pastel);
172
if (s == "pastel green") return rgb_color (pastel, 255, pastel);
173
if (s == "pastel magenta") return rgb_color (255, pastel, 255);
174
if (s == "pastel cyan") return rgb_color (pastel, 255, 255);
175
if (s == "pastel orange") return rgb_color (255, pastel, 2*pastel-255);
176
if (s == "pastel brown") return rgb_color (pastel, 2*pastel-255, 2*pastel-255);
181
get_named_color (color c) {
183
get_rgb_color (c, r, g, b);
185
as_hexadecimal (r, 2) *
186
as_hexadecimal (g, 2) *
187
as_hexadecimal (b, 2);
191
x_initialize_colors () {
192
if (the_gui->depth >= 16) {
196
CTOTAL = (CFACTOR*CFACTOR*CFACTOR+GREYS+1);
201
black = rgb_color (0, 0, 0);
202
white = rgb_color (255, 255, 255);
203
red = rgb_color (255, 0, 0);
204
blue = rgb_color (0, 0, 255);
205
yellow = rgb_color (255, 255, 0);
206
green = rgb_color (0, 255, 0);
207
magenta = rgb_color (255, 0, 255);
208
orange = rgb_color (255, 128, 0);
209
brown = rgb_color (128, 32, 0);
210
pink = rgb_color (255, 128, 128);
212
light_grey = rgb_color (208, 208, 208);
213
grey = rgb_color (184, 184, 184);
214
dark_grey = rgb_color (112, 112, 112);
217
/******************************************************************************
218
* Set up input method
219
******************************************************************************/
222
x_gui_rep::initialize_input_method () {
224
if (setlocale (LC_CTYPE, "") == NULL)
225
cerr << "TeXmacs] Warning: locale could not be set\n";
227
if (!XSetLocaleModifiers (""))
228
cerr << "TeXmacs] Warning: could not set locale modifiers\n";
229
if (XSupportsLocale () == False)
230
cerr << "TeXmacs] Warning: locale is not supported\n";
231
else if ((im = XOpenIM (dpy, NULL, NULL, NULL)) == NULL)
232
cout << "TeXmacs] Warning: could not open input method\n";
237
/******************************************************************************
239
******************************************************************************/
241
#ifndef XK_ISO_Left_Tab
242
#define XK_ISO_Left_Tab 0xFE20
245
static XModifierKeymap* xmodmap;
247
static KeyCode* mod_k;
248
static array<int> mod_shift;
249
static array<int> mod_ctrl;
250
static array<int> mod_alt;
253
x_gui_rep::insert_keysym (array<int>& a, int i, int j) {
254
int ks= XKeycodeToKeysym (dpy, mod_k[i*mod_n+j], 0);
259
x_gui_rep::get_xmodmap () {
261
xmodmap= XGetModifierMapping (dpy);
262
mod_n= xmodmap->max_keypermod;
263
mod_k= xmodmap->modifiermap;
264
for (i=0; i<mod_n; i++) {
265
insert_keysym (mod_shift, 0, i);
266
insert_keysym (mod_shift, 1, i);
267
insert_keysym (mod_ctrl, 2, i);
268
insert_keysym (mod_alt, 3, i);
270
XFreeModifiermap (xmodmap);
273
/******************************************************************************
275
******************************************************************************/
278
x_gui_rep::map (int key, string s) {
280
upper_key (key)= "S-" * s;
284
x_gui_rep::Map (int key, string s) {
290
x_gui_rep::initialize_keyboard_pointer () {
356
Map (XK_Cyrillic_a, "\xe0");
357
Map (XK_Cyrillic_be, "\xe1");
358
Map (XK_Cyrillic_ve, "\xe2");
359
Map (XK_Cyrillic_ghe, "\xe3");
360
Map (XK_Cyrillic_de, "\xe4");
361
Map (XK_Cyrillic_ie, "\xe5");
362
Map (XK_Cyrillic_io, "\xbc");
363
Map (XK_Cyrillic_zhe, "\xe6");
364
Map (XK_Cyrillic_ze, "\xe7");
365
Map (XK_Cyrillic_i, "\xe8");
366
Map (XK_Cyrillic_shorti, "\xe9");
367
Map (XK_Cyrillic_ka, "\xea");
368
Map (XK_Cyrillic_el, "\xeb");
369
Map (XK_Cyrillic_em, "\xec");
370
Map (XK_Cyrillic_en, "\xed");
371
Map (XK_Cyrillic_o, "\xee");
372
Map (XK_Cyrillic_pe, "\xef");
373
Map (XK_Cyrillic_er, "\xf0");
374
Map (XK_Cyrillic_es, "\xf1");
375
Map (XK_Cyrillic_te, "\xf2");
376
Map (XK_Cyrillic_u, "\xf3");
377
Map (XK_Cyrillic_ef, "\xf4");
378
Map (XK_Cyrillic_ha, "\xf5");
379
Map (XK_Cyrillic_tse, "\xf6");
380
Map (XK_Cyrillic_che, "\xf7");
381
Map (XK_Cyrillic_sha, "\xf8");
382
Map (XK_Cyrillic_shcha, "\xf9");
383
Map (XK_Cyrillic_hardsign, "\xfa");
384
Map (XK_Cyrillic_yeru, "\xfb");
385
Map (XK_Cyrillic_softsign, "\xfc");
386
Map (XK_Cyrillic_e, "\xfd");
387
Map (XK_Cyrillic_yu, "\xfe");
388
Map (XK_Cyrillic_ya, "\xff");
389
Map (XK_Cyrillic_A, "\xc0");
390
Map (XK_Cyrillic_BE, "\xc1");
391
Map (XK_Cyrillic_VE, "\xc2");
392
Map (XK_Cyrillic_GHE, "\xc3");
393
Map (XK_Cyrillic_DE, "\xc4");
394
Map (XK_Cyrillic_IE, "\xc5");
395
Map (XK_Cyrillic_IO, "\x9c");
396
Map (XK_Cyrillic_ZHE, "\xc6");
397
Map (XK_Cyrillic_ZE, "\xc7");
398
Map (XK_Cyrillic_I, "\xc8");
399
Map (XK_Cyrillic_SHORTI, "\xc9");
400
Map (XK_Cyrillic_KA, "\xca");
401
Map (XK_Cyrillic_EL, "\xcb");
402
Map (XK_Cyrillic_EM, "\xcc");
403
Map (XK_Cyrillic_EN, "\xcd");
404
Map (XK_Cyrillic_O, "\xce");
405
Map (XK_Cyrillic_PE, "\xcf");
406
Map (XK_Cyrillic_ER, "\xd0");
407
Map (XK_Cyrillic_ES, "\xd1");
408
Map (XK_Cyrillic_TE, "\xd2");
409
Map (XK_Cyrillic_U, "\xd3");
410
Map (XK_Cyrillic_EF, "\xd4");
411
Map (XK_Cyrillic_HA, "\xd5");
412
Map (XK_Cyrillic_TSE, "\xd6");
413
Map (XK_Cyrillic_CHE, "\xd7");
414
Map (XK_Cyrillic_SHA, "\xd8");
415
Map (XK_Cyrillic_SHCHA, "\xd9");
416
Map (XK_Cyrillic_HARDSIGN, "\xda");
417
Map (XK_Cyrillic_YERU, "\xdb");
418
Map (XK_Cyrillic_SOFTSIGN, "\xdc");
419
Map (XK_Cyrillic_E, "\xdd");
420
Map (XK_Cyrillic_YU, "\xde");
421
Map (XK_Cyrillic_YA, "\xdf");
423
//Ukrainian letters in T2A encoding
424
Map (XK_Ukrainian_i, "i"); // Fall back!
425
Map (XK_Ukrainian_I, "I"); // Fall back!
426
Map (XK_Ukrainian_yi, "\xa8");
427
Map (XK_Ukrainian_YI, "\x88");
428
Map (XK_Ukrainian_ie, "\xb9");
429
Map (XK_Ukrainian_IE, "\x99");
430
// Map (XK_Ukrainian_ghe_with_upturn, "\xa0");
431
// Map (XK_Ukrainian_GHE_WITH_UPTURN, "\x80");
435
// Standard ASCII Symbols
436
Map (XK_exclam, "!");
437
Map (XK_quotedbl, "\x22");
438
Map (XK_numbersign, "#");
439
Map (XK_dollar, "$");
440
Map (XK_percent, "%");
441
Map (XK_ampersand, "&");
442
Map (XK_apostrophe, "'");
443
Map (XK_quoteright, "'");
444
Map (XK_parenleft, "(");
445
Map (XK_parenright, ")");
446
Map (XK_asterisk, "*");
450
Map (XK_period, ".");
453
Map (XK_semicolon, ";");
456
Map (XK_greater, ">");
457
Map (XK_question, "?");
459
Map (XK_bracketleft, "[");
460
Map (XK_backslash, "\\");
461
Map (XK_bracketright, "]");
462
Map (XK_asciicircum, "^");
463
Map (XK_underscore, "_");
465
Map (XK_quoteleft, "`");
466
Map (XK_braceleft, "{");
468
Map (XK_braceright, "}");
469
Map (XK_asciitilde, "~");
472
Map (0xFE50, "grave");
473
Map (0xFE51, "acute");
475
Map (0xFE53, "tilde");
476
Map (0xFE54, "macron");
477
Map (0xFE55, "breve");
478
Map (0xFE56, "abovedot");
479
Map (0XFE57, "umlaut");
480
Map (0xFE58, "abovering");
481
Map (0xFE59, "doubleacute");
482
Map (0xFE5A, "check");
483
Map (0xFE5B, "cedilla");
484
Map (0xFE5C, "ogonek");
485
Map (0xFE5D, "iota");
486
Map (0xFE5E, "voicedsound");
487
Map (0xFE5F, "semivoicedsound");
488
Map (0xFE60, "belowdot");
490
// Extended symbols and accented characters
491
Map (XK_nobreakspace, "varspace");
492
Map (XK_exclamdown, "exclamdown");
493
Map (XK_cent, "cent");
494
Map (XK_sterling, "sterling");
495
Map (XK_currency, "currency");
497
Map (XK_brokenbar, "brokenbar");
498
Map (XK_section, "section");
499
Map (XK_diaeresis, "umlaut");
500
Map (XK_copyright, "copyright");
501
Map (XK_ordfeminine, "ordfeminine");
502
Map (XK_guillemotleft, "guillemotleft");
503
Map (XK_notsign, "notsign");
504
Map (XK_hyphen, "hyphen");
505
Map (XK_registered, "registered");
506
Map (XK_macron, "macron");
507
Map (XK_degree, "degree");
508
Map (XK_plusminus, "plusminus");
509
Map (XK_twosuperior, "twosuperior");
510
Map (XK_threesuperior, "threesuperior");
511
Map (XK_acute, "acute");
513
Map (XK_paragraph, "paragraph");
514
Map (XK_periodcentered, "periodcentered");
515
Map (XK_cedilla, "cedilla");
516
Map (XK_onesuperior, "onesuperior");
517
Map (XK_masculine, "masculine");
518
Map (XK_guillemotright, "guillemotright");
519
Map (XK_onequarter, "onequarter");
520
Map (XK_onehalf, "onehalf");
521
Map (XK_threequarters, "threequarters");
522
Map (XK_questiondown, "questiondown");
523
Map (XK_multiply, "times");
524
Map (XK_division, "div");
526
Map (XK_Agrave, "\xc0");
527
Map (XK_Aacute, "\xc1");
528
Map (XK_Acircumflex, "\xc2");
529
Map (XK_Atilde, "\xc3");
530
Map (XK_Adiaeresis, "\xc4");
531
Map (XK_Aring, "\xc5");
533
Map (XK_Ccedilla, "\xc7");
534
Map (XK_Egrave, "\xc8");
535
Map (XK_Eacute, "\xc9");
536
Map (XK_Ecircumflex, "\xca");
537
Map (XK_Ediaeresis, "\xcb");
538
Map (XK_Igrave, "\xcc");
539
Map (XK_Iacute, "\xcd");
540
Map (XK_Icircumflex, "\xce");
541
Map (XK_Idiaeresis, "\xcf");
542
Map (XK_ETH, "\xd0");
543
Map (XK_Eth, "\xd0");
544
Map (XK_Ntilde, "\xd1");
545
Map (XK_Ograve, "\xd2");
546
Map (XK_Oacute, "\xd3");
547
Map (XK_Ocircumflex, "\xd4");
548
Map (XK_Otilde, "\xd5");
549
Map (XK_Odiaeresis, "\xd6");
551
Map (XK_Ooblique, "\xd8");
552
Map (XK_Ugrave, "\xd9");
553
Map (XK_Uacute, "\xda");
554
Map (XK_Ucircumflex, "\xdb");
555
Map (XK_Udiaeresis, "\xdc");
556
Map (XK_Yacute, "\xdd");
557
Map (XK_THORN, "\xde");
558
Map (XK_Thorn, "\xde");
559
Map (XK_ssharp, "sz");
560
Map (XK_agrave, "\xe0");
561
Map (XK_aacute, "\xe1");
562
Map (XK_acircumflex, "\xe2");
563
Map (XK_atilde, "\xe3");
564
Map (XK_adiaeresis, "\xe4");
565
Map (XK_aring, "\xe5");
567
Map (XK_ccedilla, "\xe7");
568
Map (XK_egrave, "\xe8");
569
Map (XK_eacute, "\xe9");
570
Map (XK_ecircumflex, "\xea");
571
Map (XK_ediaeresis, "\xeb");
572
Map (XK_igrave, "\xec");
573
Map (XK_iacute, "\xed");
574
Map (XK_icircumflex, "\xee");
575
Map (XK_idiaeresis, "\xef");
576
Map (XK_eth, "\xf0");
577
Map (XK_ntilde, "\xf1");
578
Map (XK_ograve, "\xf2");
579
Map (XK_oacute, "\xf3");
580
Map (XK_ocircumflex, "\xf4");
581
Map (XK_otilde, "\xf5");
582
Map (XK_odiaeresis, "\xf6");
584
Map (XK_oslash, "\xf8");
585
Map (XK_ugrave, "\xf9");
586
Map (XK_uacute, "\xfa");
587
Map (XK_ucircumflex, "\xfb");
588
Map (XK_udiaeresis, "\xfc");
589
Map (XK_yacute, "\xfd");
590
Map (XK_thorn, "\xfe");
591
Map (XK_ydiaeresis, "\xff");
593
// Symbols from iso-latin-2
594
Map (XK_Aogonek, "\x81");
595
Map (XK_breve, "breve");
596
Map (XK_Lstroke, "\x8a");
597
Map (XK_Lcaron, "\x89");
598
Map (XK_Sacute, "\x91");
599
Map (XK_Scaron, "\x92");
600
Map (XK_Scedilla, "\x93");
601
Map (XK_Tcaron, "\x94");
602
Map (XK_Zacute, "\x99");
603
Map (XK_Zcaron, "\x9a");
604
Map (XK_Zabovedot, "\x9b");
605
Map (XK_aogonek, "\xa1");
606
Map (XK_ogonek, "ogonek");
607
Map (XK_lstroke, "\xaa");
608
Map (XK_lcaron, "\xa9");
609
Map (XK_sacute, "\xb1");
610
Map (XK_caron, "caron");
611
Map (XK_scaron, "\xb2");
612
Map (XK_scedilla, "\xb3");
613
Map (XK_tcaron, "\xb4");
614
Map (XK_zacute, "\xb9");
615
Map (XK_doubleacute, "doubleacute");
616
Map (XK_zcaron, "\xba");
617
Map (XK_zabovedot, "\xbb");
618
Map (XK_Racute, "\x8f");
619
Map (XK_Abreve, "\x80");
620
Map (XK_Lacute, "\x88");
621
Map (XK_Cacute, "\x82");
622
Map (XK_Ccaron, "\x83");
623
Map (XK_Eogonek, "\x86");
624
Map (XK_Ecaron, "\x85");
625
Map (XK_Dcaron, "\x84");
626
Map (XK_Dstroke, "\xd0");
627
Map (XK_Nacute, "\x8b");
628
Map (XK_Ncaron, "\x8c");
629
Map (XK_Odoubleacute, "\x8e");
630
Map (XK_Rcaron, "\x90");
631
Map (XK_Uring, "\x97");
632
Map (XK_Udoubleacute, "\x96");
633
Map (XK_Tcedilla, "\x95");
634
Map (XK_racute, "\xaf");
635
Map (XK_abreve, "\xa0");
636
Map (XK_lacute, "\xa8");
637
Map (XK_cacute, "\xa2");
638
Map (XK_ccaron, "\xa3");
639
Map (XK_eogonek, "\xa6");
640
Map (XK_ecaron, "\xa5");
641
Map (XK_dcaron, "\xa4");
642
Map (XK_dstroke, "\x9e");
643
Map (XK_nacute, "\xab");
644
Map (XK_ncaron, "\xac");
645
Map (XK_odoubleacute, "\xae");
646
Map (XK_udoubleacute, "\xb6");
647
Map (XK_rcaron, "\xb0");
648
Map (XK_uring, "\xb7");
649
Map (XK_tcedilla, "\xb5");
650
Map (XK_abovedot, "abovedot");
652
// Special control keys
653
Map (XK_Prior, "pageup");
654
Map (XK_Next, "pagedown");
655
Map (XK_Undo, "undo");
656
Map (XK_Redo, "redo");
657
Map (XK_Cancel, "cancel");
660
map (XK_space, "space");
661
map (XK_Return, "return");
662
map (XK_BackSpace, "backspace");
663
map (XK_Delete, "delete");
664
map (XK_Insert, "insert");
666
map (XK_ISO_Left_Tab, "tab");
667
map (XK_Escape, "escape");
668
map (XK_Left, "left");
669
map (XK_Right, "right");
671
map (XK_Down, "down");
672
map (XK_Page_Up, "pageup");
673
map (XK_Page_Down, "pagedown");
674
map (XK_Home, "home");
688
// map (XK_Mode_switch, "modeswitch");
691
Map (XK_KP_Space, "K-space");
692
Map (XK_KP_Enter, "K-return");
693
Map (XK_KP_Delete, "K-delete");
694
Map (XK_KP_Insert, "K-insert");
695
Map (XK_KP_Tab, "K-tab");
696
Map (XK_KP_Left, "K-left");
697
Map (XK_KP_Right, "K-right");
698
Map (XK_KP_Up, "K-up");
699
Map (XK_KP_Down, "K-down");
700
Map (XK_KP_Page_Up, "K-pageup");
701
Map (XK_KP_Page_Down, "K-pagedown");
702
Map (XK_KP_Home, "K-home");
703
Map (XK_KP_Begin, "K-begin");
704
Map (XK_KP_End, "K-end");
705
Map (XK_KP_F1, "K-F1");
706
Map (XK_KP_F2, "K-F2");
707
Map (XK_KP_F3, "K-F3");
708
Map (XK_KP_F4, "K-F4");
709
Map (XK_KP_Equal, "K-=");
710
Map (XK_KP_Multiply, "K-*");
711
Map (XK_KP_Add, "K-+");
712
Map (XK_KP_Subtract, "K--");
713
Map (XK_KP_Decimal, "K-.");
714
Map (XK_KP_Separator, "K-,");
715
Map (XK_KP_Divide, "K-/");
716
Map (XK_KP_0, "K-0");
717
Map (XK_KP_1, "K-1");
718
Map (XK_KP_2, "K-2");
719
Map (XK_KP_3, "K-3");
720
Map (XK_KP_4, "K-4");
721
Map (XK_KP_5, "K-5");
722
Map (XK_KP_6, "K-6");
723
Map (XK_KP_7, "K-7");
724
Map (XK_KP_8, "K-8");
725
Map (XK_KP_9, "K-9");
728
Map (SunXK_FA_Grave, "grave");
729
Map (SunXK_FA_Circum, "hat");
730
Map (SunXK_FA_Tilde, "tilde");
731
Map (SunXK_FA_Acute, "acute");
732
Map (SunXK_FA_Diaeresis, "umlaut");
733
Map (SunXK_FA_Cedilla, "cedilla");
734
Map (SunXK_F36, "F11");
735
Map (SunXK_F37, "F12");
736
Map (SunXK_Copy, "copy");
737
Map (SunXK_Paste, "paste");
738
Map (SunXK_Cut, "cut");
739
// Map (XK_L1, "stop"); On Sun, but conflicts with F11
740
// Map (XK_L2, "again"); On Sun, but conflicts with F12
741
Map (XK_L3, "props");
743
Map (XK_L5, "front");
746
Map (XK_L8, "paste");
751
Map (0x20ac, "euro");
754
/******************************************************************************
756
******************************************************************************/
759
x_gui_rep::get_extents (SI& width, SI& height) {
760
width = screen_width * PIXEL;
761
height= screen_height * PIXEL;
765
x_gui_rep::get_max_size (SI& width, SI& height) {
766
width = 8000 * PIXEL;
767
height= 6000 * PIXEL;
770
/******************************************************************************
771
* Main initialization
772
******************************************************************************/
774
x_gui_rep::x_gui_rep (int argc2, char** argv2):
775
color_scale ((void*) NULL),
776
character_bitmap (NULL), character_pixmap ((pointer) 0),
777
xpm_bitmap (0), xpm_pixmap (0),
778
lower_key (""), upper_key (""),
779
selection (NULL), selection_t ("none"), selection_s ("")
782
if ((dpy= XOpenDisplay (NULL)) == NULL)
783
fatal_error ("I failed to connect to Xserver", "x_gui_rep::x_gui_rep");
784
// XSynchronize (dpy, true);
789
scr = DefaultScreen (dpy);
790
root = RootWindow (dpy, scr);
791
gc = XCreateGC (dpy, root, 0, &values);
792
pixmap_gc = XCreateGC (dpy, root, 0, &values);
793
depth = DefaultDepth (dpy, scr);
794
screen_width = DisplayWidth (dpy, scr);
795
screen_height = DisplayHeight (dpy, scr);
796
cols = DefaultColormap (dpy, DefaultScreen (dpy));
803
interrupt_time = texmacs_time ();
805
if (XMatchVisualInfo (dpy, scr, depth, TrueColor, &visual) != 0) {
806
if (visual.red_mask == (255 << 16) &&
807
visual.green_mask == (255 << 8) &&
808
visual.blue_mask == 255)
812
XSetGraphicsExposures (dpy, gc, true);
815
x_initialize_colors ();
816
initialize_input_method ();
817
initialize_keyboard_pointer ();
818
set_output_language (get_locale_language ());
819
(void) default_font ();
822
x_gui_rep::~x_gui_rep () {
823
if (im_ok) XCloseIM (im);
824
clear_selection ("primary");
827
if (!true_color) delete[] cmap;
831
gui_open (int argc2, char** argv2) {
833
fatal_error ("gui already open", "gui_open");
834
the_gui= new x_gui_rep (argc2, argv2);
839
the_gui->event_loop ();
845
fatal_error ("gui not yet open", "gui_close");
851
gui_root_extents (SI& width, SI& height) {
852
the_gui->get_extents (width, height);
856
gui_maximal_extents (SI& width, SI& height) {
857
the_gui->get_max_size (width, height);
862
iterator<Window> it= iterate (Window_to_window);
864
x_window win= (x_window) Window_to_window [it->next()];
865
if (get_x_window (win->w) != NULL)
866
send_update (win->w);