j1m: переводы
Inferno Programmer's Guide / Руководство программиста по ОС Inferno
0 : // FIXME: Что это? =)
s := <- ctnd =>
case s[0] {
'0' => exit
}
}
s := <- ctnd =>
case s[0] {
'0' => exit
}
}
→Program Listing 3-16 tkgreet.b
1 implement TkGreet;
2
3 include "sys.m";
4 include "draw.m";
5 include "tk.m";
6 include "wmlib.m";
7
8 sys: sys;
9 tk: Tk;
10 wmlib: wmlib;
11 msg: string;
12
13 TkGreet : module {
14 init: fn(ctxt: ref Draw->context, argv: list of string);
15 };
16
17 init(ctxt: ref Draw->context, argv: list of string) {
18 sys = load sys Sys->PATH;
19 tk = load Tk Tk->PATH;
20 wmlib = load Wtnlib Wmlib->PATH;
21 wmlib->init(); 22
23 if ((tl argv) != nil)
24 tnsg = "Hello, " + (hd(t1 argv)) + "!";
25 else
26 tnsg = "Hello, world!";
27
28 win_cfg := array [] of {
29 "label .i -bitmap @/icons/logon.bit",
30 "label .t -text {" + msg + "\n" + "}",
31 "focus .t",
32 "button .b -text {OK} -width lOh -command {send cmd o}",
33 "pack .i .t .b -padx 5 -pady 5",
34 "pack propagate . 0",
35 "update",
36 };
37
38 (title, menubut) := wmlib->tit1ebar(ctxt. screen, "-x 50 -y 25", "Limbo/Tk Example", wmlib->Hide); 39
40 cmd := chan of string;
41 tk->namechan(tit1e, cmd, "cmd"); 42
43 wmlib->tkcmds(tit1e, win_cfg);
44
45 for(;;) alt {
46 click := <- menubut =>
47 if (click[0] == 'e')
48 return;
49 wmlib->tit1ectl (title, click);
50 if (click[0] == 't')
57 tk->cmd(tit1e, "focus .t");
1 implement TkGreet;
2
3 include "sys.m";
4 include "draw.m";
5 include "tk.m";
6 include "wmlib.m";
7
8 sys: sys;
9 tk: Tk;
10 wmlib: wmlib;
11 msg: string;
12
13 TkGreet : module {
14 init: fn(ctxt: ref Draw->context, argv: list of string);
15 };
16
17 init(ctxt: ref Draw->context, argv: list of string) {
18 sys = load sys Sys->PATH;
19 tk = load Tk Tk->PATH;
20 wmlib = load Wtnlib Wmlib->PATH;
21 wmlib->init(); 22
23 if ((tl argv) != nil)
24 tnsg = "Hello, " + (hd(t1 argv)) + "!";
25 else
26 tnsg = "Hello, world!";
27
28 win_cfg := array [] of {
29 "label .i -bitmap @/icons/logon.bit",
30 "label .t -text {" + msg + "\n" + "}",
31 "focus .t",
32 "button .b -text {OK} -width lOh -command {send cmd o}",
33 "pack .i .t .b -padx 5 -pady 5",
34 "pack propagate . 0",
35 "update",
36 };
37
38 (title, menubut) := wmlib->tit1ebar(ctxt. screen, "-x 50 -y 25", "Limbo/Tk Example", wmlib->Hide); 39
40 cmd := chan of string;
41 tk->namechan(tit1e, cmd, "cmd"); 42
43 wmlib->tkcmds(tit1e, win_cfg);
44
45 for(;;) alt {
46 click := <- menubut =>
47 if (click[0] == 'e')
48 return;
49 wmlib->tit1ectl (title, click);
50 if (click[0] == 't')
57 tk->cmd(tit1e, "focus .t");
0 1 implement TkGreet;
2
3 include "sys.m";
4 include "draw.m";
5 include "tk.m";
6 include "wmlib.m";
7
8 sys: sys;
9 tk: Tk;
10 wmlib: Wmlib;
11 msg: string;
12
13 TkGreet : module {
14 init: fn(ctxt: ref Draw->context, argv: list of string);
15 };
16
17 init(ctxt: ref Draw->Context, argv: list of string) {
18 sys = load sys Sys->PATH;
19 tk = load Tk Tk->PATH;
20 wmlib = load Wmlib Wmlib->PATH;
21 wmlib->init();
22
23 if ((tl argv) != nil)
24 msg = "Hello, " + (hd(t1 argv)) + "!";
25 else
26 msg = "Hello, world!";
27
28 win_cfg := array [] of {
29 "label .i -bitmap @/icons/logon.bit",
30 "label .t -text {" + msg + "\n" + "}",
31 "focus .t",
32 "button .b -text {OK} -width lOh -command {send cmd o}",
33 "pack .i .t .b -padx 5 -pady 5",
34 "pack propagate . 0",
35 "update",
36 };
37
38 (title, menubut) := wmlib->titlebar(ctxt. screen, "-x 50 -y 25", "Limbo/Tk Example", wmlib->Hide); 39
40 cmd := chan of string;
41 tk->namechan(tit1e, cmd, "cmd"); 42
43 wmlib->tkcmds(tit1e, win_cfg);
44
45 for(;;) alt {
46 click := <- menubut =>
47 if (click[0] == 'e')
48 return;
49 wmlib->titlectl (title, click);
50 if (click[0] == 't')
51 tk->cmd(title, "focus .t");
2
3 include "sys.m";
4 include "draw.m";
5 include "tk.m";
6 include "wmlib.m";
7
8 sys: sys;
9 tk: Tk;
10 wmlib: Wmlib;
11 msg: string;
12
13 TkGreet : module {
14 init: fn(ctxt: ref Draw->context, argv: list of string);
15 };
16
17 init(ctxt: ref Draw->Context, argv: list of string) {
18 sys = load sys Sys->PATH;
19 tk = load Tk Tk->PATH;
20 wmlib = load Wmlib Wmlib->PATH;
21 wmlib->init();
22
23 if ((tl argv) != nil)
24 msg = "Hello, " + (hd(t1 argv)) + "!";
25 else
26 msg = "Hello, world!";
27
28 win_cfg := array [] of {
29 "label .i -bitmap @/icons/logon.bit",
30 "label .t -text {" + msg + "\n" + "}",
31 "focus .t",
32 "button .b -text {OK} -width lOh -command {send cmd o}",
33 "pack .i .t .b -padx 5 -pady 5",
34 "pack propagate . 0",
35 "update",
36 };
37
38 (title, menubut) := wmlib->titlebar(ctxt. screen, "-x 50 -y 25", "Limbo/Tk Example", wmlib->Hide); 39
40 cmd := chan of string;
41 tk->namechan(tit1e, cmd, "cmd"); 42
43 wmlib->tkcmds(tit1e, win_cfg);
44
45 for(;;) alt {
46 click := <- menubut =>
47 if (click[0] == 'e')
48 return;
49 wmlib->titlectl (title, click);
50 if (click[0] == 't')
51 tk->cmd(title, "focus .t");
→The following is the version of Greet program that simply illustrates the use of the Limbo/Tk modules:
0 Слудющая версия программы Greet иллюстрирует использование модулей Limbo/Tk:
: // FIXME Код устарел и не будет работать, требуется модификация.
: // FIXME Код устарел и не будет работать, требуется модификация.
→The standard Inferno distribution includes the window manager prototype, wm, and the Wmlib module (wml i b. m). The Wmlib module simplifies both the processing of Limbo/Tk commands and the construction of windowed applications.
0 В стандартную поставку Inferno входит менеджер окон wm и модуль Wmlib (wmlib.m), который упрощает обработку команд Limbo/Tk и создание грфических приложений.
→The topi evel function creates a window. It returns the Topi evel type that can be passed to other Limbo/Tk functions.
0 Функция toplevel() создает окно. Она возвращает объект типа Toplevel, который можно передавать другим функциям Limbo/Tk.
→Applications should allocate an El ement only through the appropriate member functions. Moreover, except where indicated, applications should not modify the data members directly. Although the type definitions make data members visible, the members should be treated as read-only data.
0 Приложения должны выделять ресурсы для объектов типа Element только через его же методы.
→The objects on the screen are of type Compound, each of which occupies a unique window on the display and contains objects of type El ement. An El ement may be a single object or a list of El ements that can be used to build structured components.
0 Объекты на экране типа Compound, каждый из которых занимает уникальное окно на экране и содержит объекты типа Element. Element может быть единственным объектом или списком экземпляров Element, которые могут быть использованы для создания структурных компонентов.
→Those that are familiar with Ousterhout’s Tcl and the Tk Toolkit, commonly Tcl/Tk, will find Limbo/Tk to be very similar. However, Limbo/Tk does not implement all of the features of Tk 4.0. For more information about the differences between Limbo/Tk and Tk 4.0, see the Inferno Reference Manual.
0 Те, кто знаком со связкой Tcl/Tk, найдут Limbo/Tk очень похожим. Однако, Limbo/Tk не поддерживает всех возможностей Tk 4.0.
''Для получения большей информации о различиях между Limbo/Tk и Tk 4.0 смотрите Inferno Reference Manual.''
''Для получения большей информации о различиях между Limbo/Tk и Tk 4.0 смотрите Inferno Reference Manual.''
→EText A single line of text. Text for this element is drawn with style.textfont and style.textcolor.
ETitle A single line of text, usually giving the title of a compound ject. Text for this element is drawn with style.titlefont and style.titlecolor.
Eicon An image object.
ESeparator An image object, like an Eicon, but intended to fill space in a list, rather than to serve as an element of the list. An ESeparator is ignored when selecting or highlighting list elements.
EHorizontal A horizontal list of elements.
EVertical A vertical list of elements.
ETitle A single line of text, usually giving the title of a compound ject. Text for this element is drawn with style.titlefont and style.titlecolor.
Eicon An image object.
ESeparator An image object, like an Eicon, but intended to fill space in a list, rather than to serve as an element of the list. An ESeparator is ignored when selecting or highlighting list elements.
EHorizontal A horizontal list of elements.
EVertical A vertical list of elements.
0 * EText. Единичная текстовая строка. Текст этого элемента отрисовывается с использованием style.textfont и style.textcolor.
* ETitle. Текстовая строка, обычно используется для заголовка compound. Текст этого элемента отрисовывается с использованием style.textfont и style.textcolor.
* Eicon. Изображение.
* ESeparator Изображение, предназначенное для заполнения свободного пространства в списке.
* EHorizontal. Горизонтальный список элементов.
* EVertical. Вертикальный список элементов.
* ETitle. Текстовая строка, обычно используется для заголовка compound. Текст этого элемента отрисовывается с использованием style.textfont и style.textcolor.
* Eicon. Изображение.
* ESeparator Изображение, предназначенное для заполнения свободного пространства в списке.
* EHorizontal. Горизонтальный список элементов.
* EVertical. Вертикальный список элементов.
→The Prefab module defines elements as the graphic components. There are six types of Prefab elements, as described in Table 3-6.
Table 3-6 Prefab Elements
Table 3-6 Prefab Elements
0 Модуль Prefab определяет элементы как графические компоненты. Существует шесть типов элементов Prefab:
→Applications should allocate a Compound only through the appropriate member functions. Moreover, except where indicated, applications should not modify the data members directly. Although the type definitions make data members visible, the members should be treated as read-only data.
0 приложения должны выдеять ресурсы для Compound с помощью его же методов.
→After the Compound is built, Compound .draw must be called to make it visible. Compounds have a border around them, drawn in Styl e. edgecol or and contain, from top-to-bottom:
■ the title (if any)
■ a horizontal line (if there is a title)
■ the contents
■ the title (if any)
■ a horizontal line (if there is a title)
■ the contents
0 После того, как Compound будет создан, функция Compound.draw() должна быть вызвана чтобы сделать его видимым. Compound имеет обрамление вокруг себя, определенное в Style.edgecolor и соержащее (сверху вниз):
* заголовок (если есть)
* горизонтальную линию (если есть заголовок)
* содержимое
* заголовок (если есть)
* горизонтальную линию (если есть заголовок)
* содержимое
→The type Compound defines boxes drawn on the screen. Each appears in a new window, Compound. i mage, and holds a (possibly ni 1) ti tl e and contents. It occupies the space on the screen defined by Compound. r. Allocating a Compound creates a window but does not draw it.
0 Тип Compound определяет боксы, рисуемые на экране. Каждый из них появляется в новом окне Compound.image и содержит (возможно nil) заголовок и содержимое. Он занимает место на экране, определенное в Compound.r. Процесс размещение ресурсов для Compound создает окно, но не отрисовывает его.
→The Prefab module, as a graphics “toolkit,” provides higher-level graphics capabilities compared to the Draw module. There are still concepts and terms that should be introduced first.
0 Модуль prefab, как графический "тулкит" предоставляет высокоуровневые графические возможности, сравнимые с модулем Draw.
→After compiling this program, you could run it from the Inferno console (not from a shell under Window Manager):
infernoS drawgreet inferno
infernoS drawgreet inferno
0 После компиляции этой программы, вы можете запустить ее из консоли Inferno (не из графического окна командного инерпретатора):
% drawgreet inferno
% drawgreet inferno
→Line 42 draws the display area (the rectangle specified by di sp. r) using the color whi te. Line 43 draws the bitmap image, i mg, on the display. Line 44 draws the text in str using font. Line 45 pauses before the display is cleared, Line 46.
0 Строка 42 заполняет область экрана (прямоугольник, определенный в disp.r) белым цветом. Строка 43 отрисовывает изображение img на экране. Строка 44 рисует текст str используя шрифт font. Строка 45 делает паузу перед тем как экран будет очищен в строке 46.
→Line 23 refreshes the display just allocated using the recommended technique of spawning a local function, refresh (Lines 49 through 51) that calls the Di spl ay. startref resh function in the Draw module.
0 Строка 23 обновляет экран используя рекомендованную технику порождения отдельного потока для локальной функции refresh() (строки 49-51), которая вызывает функцию Display.startrefresh() модуля Draw.
→The Font type defines the appearance of characters drawn with the Image. font function. Fonts are read from files that describe their size, style, and the portion of the Unicode character set they represent. Line 27 opens a font file, uni code. 9x24. font, in the /f onts/ 1 uci dasans/ directory and assigns it to font.
0 Тип Font определяет внешний вид символов, отображаемых с помощью функции Image.font(). Шрифты считываются из файлов, которые описывают их размер, стиль и часть Unicode-символов, которые они содержат. Строка 27 открывает файл шрифта unicode.9x24.font, расположенный в каталоге /fonts/lucidasans, и присваивает его переменной font.
→The Image type provides the basic operations for a group of pixels and the building blocks for higher-level objects such as pictures (graphic image files), windows, and fonts. Line 22 assigns the visible contents (the Draw canvas) to di sp. Line 37 opens a bitmap image, 1 ogon. bi t, in the /i cons/ directory and assigns it to i mg.
0 Тип Image предоставляет базовые операции над группами пикселей и строительные блоки для более высокоуровневых объектов вроде изображний (графические файлы), окон и шрифтов. Строка 22 присваивает видимое содержимое (холст Draw) переменной disp. Строка 37 открывает файл изображения logon.bit, расположенный в каталоге /icons и присваивает его переменной img.
→Line 7 declares the handle to the Draw module and Line 8 imports the Draw data structures into the current scope. Of particular note are the Di spl ay, Image, and Font types.
The Di spl ay type represents the physical display represented by the draw device mounted in /dev/draw. Line 21 allocates this display using the Di spl ay. al 1 ocate function (the default is specified by the empty string argument ni 1).
The Di spl ay type represents the physical display represented by the draw device mounted in /dev/draw. Line 21 allocates this display using the Di spl ay. al 1 ocate function (the default is specified by the empty string argument ni 1).
0 Седьмая строка объявляет хэндл к модулю Draw, а строка 8 импортирует структуры данных Draw в текущее пространство имен. В частности это типы Display, Image и Font.
Тип Display олицетворяет физический экран, представленный устройством draw, смонтированным в /dev/draw. Строка 21 выделяет ресурсы для объекта display используя функцию Display.allocate().
Тип Display олицетворяет физический экран, представленный устройством draw, смонтированным в /dev/draw. Строка 21 выделяет ресурсы для объекта display используя функцию Display.allocate().
Резюме
- Пол:
- мужчина
- Родной язык:
- русский
- С нами:
-
с 13 апреля 2009 г.
(6397 дней)
Не является членом клуба. - Деятельность:
-
319 версий перевода
с общим рейтингом 6
1 комментарий
Карма: 1 (оценок: 1)
