1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-01 06:24:58 +03:00
inform7/inter/index-module/Chapter 3/Innards Element.w

208 lines
7.4 KiB
OpenEdge ABL
Raw Normal View History

2021-06-10 00:20:23 +03:00
[InnardsElement::] Innards Element.
To write the Innards element (In) in the index.
2021-07-25 17:11:01 +03:00
@ This element is something of a miscellany, except that it's all about the
technical implementation rather than the content of a work.
2021-06-10 00:20:23 +03:00
=
2021-07-26 15:48:49 +03:00
void InnardsElement::render(OUTPUT_STREAM, index_session *session) {
localisation_dictionary *LD = Indexing::get_localisation(session);
inter_tree *I = Indexing::get_tree(session);
tree_inventory *inv = Indexing::get_inventory(session);
2022-02-03 01:35:38 +02:00
InterNodeList::array_sort(inv->use_option_nodes, MakeSynopticModuleStage::module_order);
2021-06-10 00:20:23 +03:00
@<Show the virtual machine compiled for@>;
@<Show the use options@>;
HTML_OPEN("p");
2021-07-09 00:56:01 +03:00
IndexUtilities::extra_link(OUT, 3);
2021-07-26 02:34:51 +03:00
Localisation::roman(OUT, LD, I"Index.Elements.In.Technicalities");
2021-06-10 00:20:23 +03:00
HTML_CLOSE("p");
2021-07-09 00:56:01 +03:00
IndexUtilities::extra_div_open(OUT, 3, 2, "e0e0e0");
2021-06-10 00:20:23 +03:00
HTML_OPEN("p");
2021-07-09 00:56:01 +03:00
IndexUtilities::anchor(OUT, I"CONFIG");
2021-07-27 15:55:53 +03:00
HTML_CLOSE("p");
2021-06-10 00:20:23 +03:00
@<Show the language elements used@>;
@<Add some paste buttons for the debugging log@>;
2021-07-09 00:56:01 +03:00
IndexUtilities::extra_div_close(OUT, "e0e0e0");
2021-06-10 00:20:23 +03:00
}
@<Show the virtual machine compiled for@> =
2021-07-09 00:56:01 +03:00
IndexUtilities::anchor(OUT, I"STORYFILE");
2021-07-25 17:11:01 +03:00
HTML_OPEN("p");
2021-07-26 02:34:51 +03:00
Localisation::roman(OUT, LD, I"Index.Elements.In.Format");
2021-07-25 17:11:01 +03:00
WRITE(": ");
2022-02-03 17:51:44 +02:00
inter_package *pack = InterPackage::from_URL(I, I"/main/completion/basics");
text_stream *VM = Metadata::optional_textual(pack, I"^virtual_machine");
text_stream *VM_icon = Metadata::optional_textual(pack, I"^virtual_machine_icon");
2021-06-10 00:20:23 +03:00
if (Str::len(VM_icon) > 0) {
HTML_TAG_WITH("img", "border=0 src=inform:/doc_images/%S", VM_icon);
WRITE("&nbsp;");
}
if (Str::len(VM) > 0) WRITE("%S", VM);
HTML_CLOSE("p");
@<Show the use options@> =
2021-07-25 17:11:01 +03:00
HTML_OPEN("p");
2021-07-26 02:34:51 +03:00
Localisation::roman(OUT, LD, I"Index.Elements.In.ActiveUseOptions");
2021-07-25 17:11:01 +03:00
WRITE(":");
HTML_CLOSE("p");
InnardsElement::index_options_in_force_from(OUT, inv, MAIN_TEXT_UO_ORIGIN, NULL, LD);
InnardsElement::index_options_in_force_from(OUT, inv, OPTIONS_FILE_UO_ORIGIN, NULL, LD);
2021-07-25 00:04:35 +03:00
inter_package *E;
LOOP_OVER_INVENTORY_PACKAGES(E, i, inv->module_nodes)
2021-07-25 17:11:01 +03:00
InnardsElement::index_options_in_force_from(OUT, inv, EXTENSION_UO_ORIGIN, E, LD);
2021-06-10 00:20:23 +03:00
int c = 0;
2021-07-25 17:11:01 +03:00
HTML_OPEN("p");
2021-07-26 02:34:51 +03:00
Localisation::roman(OUT, LD, I"Index.Elements.In.InactiveUseOptions");
2021-07-25 17:11:01 +03:00
WRITE(":");
HTML_CLOSE("p");
2021-06-10 00:20:23 +03:00
HTML::open_indented_p(OUT, 2, "tight");
2021-07-25 00:04:35 +03:00
inter_package *pack;
LOOP_OVER_INVENTORY_PACKAGES(pack, i, inv->use_option_nodes) {
2021-06-10 00:20:23 +03:00
inter_ti set = Metadata::read_numeric(pack, I"^active");
inter_ti sfs = Metadata::read_numeric(pack, I"^source_file_scoped");
if ((set == FALSE) && (sfs == FALSE)) {
@<Write in the index line for a use option not taken@>;
if (c++ > 0) WRITE(", ");
}
}
2021-07-26 02:34:51 +03:00
if (c == 0) Localisation::roman(OUT, LD, I"Index.Elements.In.NoUseOptions");
2021-06-10 00:20:23 +03:00
HTML_CLOSE("p");
@<Write in the index line for a use option not taken@> =
HTML_OPEN_WITH("span", "style=\"white-space:nowrap\";");
TEMPORARY_TEXT(TEMP)
WRITE_TO(TEMP, "Use %S.", Metadata::required_textual(pack, I"^name"));
2021-06-10 00:20:23 +03:00
PasteButtons::paste_text(OUT, TEMP);
DISCARD_TEXT(TEMP)
WRITE("&nbsp;%S", Metadata::required_textual(pack, I"^name"));
2021-06-10 00:20:23 +03:00
HTML_CLOSE("span");
@<Show the language elements used@> =
2021-07-25 17:11:01 +03:00
HTML_OPEN("p");
2021-07-26 02:34:51 +03:00
Localisation::roman(OUT, LD, I"Index.Elements.In.LanguageDefinition");
2021-07-25 17:11:01 +03:00
WRITE(":");
HTML_CLOSE("p");
HTML_OPEN("p");
2022-02-03 17:51:44 +02:00
inter_package *pack = InterPackage::from_URL(I, I"/main/completion/basics");
text_stream *used = Metadata::optional_textual(pack, I"^language_elements_used");
text_stream *not_used = Metadata::optional_textual(pack, I"^language_elements_not_used");
2021-07-25 17:11:01 +03:00
if (Str::len(used) > 0)
2021-07-26 02:34:51 +03:00
Localisation::roman_t(OUT, LD, I"Index.Elements.In.Included", used);
2021-07-25 17:11:01 +03:00
if ((Str::len(used) > 0) && (Str::len(not_used) > 0)) WRITE("<br>");
if (Str::len(not_used) > 0)
2021-07-26 02:34:51 +03:00
Localisation::roman_t(OUT, LD, I"Index.Elements.In.Excluded", not_used);
2021-06-10 00:20:23 +03:00
HTML_CLOSE("p");
@<Add some paste buttons for the debugging log@> =
HTML_OPEN("p");
2021-07-26 02:34:51 +03:00
Localisation::roman(OUT, LD, I"Index.Elements.In.Log");
2021-07-25 17:11:01 +03:00
WRITE(":");
2021-06-10 00:20:23 +03:00
HTML_CLOSE("p");
HTML_OPEN("p");
2022-02-03 17:51:44 +02:00
inter_package *pack = InterPackage::from_URL(I, I"/main/completion/basics");
2021-07-24 20:16:56 +03:00
inter_package *aspect_pack;
LOOP_THROUGH_SUBPACKAGES(aspect_pack, pack, I"_debugging_aspect") {
TEMPORARY_TEXT(is)
WRITE_TO(is, "Include %S in the debugging log.",
Metadata::required_textual(aspect_pack, I"^name"));
2021-07-24 20:16:56 +03:00
PasteButtons::paste_text(OUT, is);
WRITE("&nbsp;%S&nbsp;", is);
DISCARD_TEXT(is)
if (Metadata::read_optional_numeric(aspect_pack, I"^used")) {
HTML_TAG_WITH("img", "border=0 src=inform:/doc_images/tick.png");
} else {
HTML_TAG_WITH("img", "border=0 src=inform:/doc_images/cross.png");
2021-06-10 00:20:23 +03:00
}
2021-07-24 20:16:56 +03:00
HTML_TAG("br");
2021-06-10 00:20:23 +03:00
}
HTML_CLOSE("p");
2021-07-25 17:11:01 +03:00
@ Use options can be set in three general ways, and the following function
answers the question "was this option set in this way?". |E| is meaningless
except for |EXTENSION_UO_ORIGIN|, when we are testing whether it was set in |E|.
2021-06-10 00:20:23 +03:00
@d MAIN_TEXT_UO_ORIGIN 1
@d OPTIONS_FILE_UO_ORIGIN 2
@d EXTENSION_UO_ORIGIN 3
=
2021-07-25 17:11:01 +03:00
int InnardsElement::uo_set_from(inter_package *pack, int way, inter_package *E) {
switch (way) {
case MAIN_TEXT_UO_ORIGIN:
if (Metadata::read_optional_numeric(pack, I"^used_in_source_text")) return TRUE;
break;
case OPTIONS_FILE_UO_ORIGIN:
if (Metadata::read_optional_numeric(pack, I"^used_in_options")) return TRUE;
break;
case EXTENSION_UO_ORIGIN: {
inter_symbol *id = Metadata::optional_symbol(pack, I"^used_in_extension");
2021-07-25 17:11:01 +03:00
if (id) {
2022-01-31 01:49:12 +02:00
inter_package *used_in_E = InterPackage::container(id->definition);
2021-07-25 17:11:01 +03:00
if ((used_in_E) && (used_in_E == E)) return TRUE;
}
break;
}
}
return FALSE;
}
@ Here we list the UOs set in a particular way, using the same calling conventions.
=
void InnardsElement::index_options_in_force_from(OUTPUT_STREAM, tree_inventory *inv,
int way, inter_package *E, localisation_dictionary *LD) {
2021-06-10 00:20:23 +03:00
int N = 0;
2021-07-25 00:04:35 +03:00
inter_package *pack;
LOOP_OVER_INVENTORY_PACKAGES(pack, i, inv->use_option_nodes) {
2021-06-10 00:20:23 +03:00
inter_ti set = Metadata::read_numeric(pack, I"^active");
inter_ti sfs = Metadata::read_numeric(pack, I"^source_file_scoped");
if ((set) && (sfs == FALSE)) {
2021-07-25 17:11:01 +03:00
if (InnardsElement::uo_set_from(pack, way, E)) {
2021-06-10 00:20:23 +03:00
if (N++ == 0) @<Write in the use option subheading@>;
@<Write in the index line for a use option taken@>;
}
}
}
}
@<Write in the use option subheading@> =
HTML::open_indented_p(OUT, 2, "tight");
HTML::begin_colour(OUT, I"808080");
2021-07-25 17:11:01 +03:00
switch (way) {
2021-06-10 00:20:23 +03:00
case MAIN_TEXT_UO_ORIGIN:
2021-07-26 02:34:51 +03:00
Localisation::roman(OUT, LD, I"Index.Elements.In.SetFromSource");
2021-07-25 17:11:01 +03:00
break;
2021-06-10 00:20:23 +03:00
case OPTIONS_FILE_UO_ORIGIN:
2021-07-26 02:34:51 +03:00
Localisation::roman(OUT, LD, I"Index.Elements.In.SetAutomatically");
DocReferences::link(OUT, I"OPTIONSFILE"); break;
2021-06-10 00:20:23 +03:00
case EXTENSION_UO_ORIGIN:
2021-07-26 02:34:51 +03:00
Localisation::roman_t(OUT, LD, I"Index.Elements.In.SetFrom",
Metadata::optional_textual(E, I"^credit"));
2021-06-10 00:20:23 +03:00
break;
}
WRITE(":");
HTML::end_colour(OUT);
HTML_CLOSE("p");
@<Write in the index line for a use option taken@> =
HTML::open_indented_p(OUT, 3, "tight");
WRITE("Use %S", Metadata::optional_textual(pack, I"^name"));
2021-06-10 00:20:23 +03:00
int msv = (int) Metadata::read_optional_numeric(pack, I"^minimum");
if (msv > 0) WRITE(" of at least %d", msv);
int at = (int) Metadata::read_optional_numeric(pack, I"^used_at");
2021-07-09 00:56:01 +03:00
if (at > 0) IndexUtilities::link(OUT, at);
2021-06-10 00:20:23 +03:00
if (msv > 0) {
WRITE("&nbsp;");
TEMPORARY_TEXT(TEMP)
WRITE_TO(TEMP, "Use %S of at least %d.",
Metadata::optional_textual(pack, I"^name"), 2*msv);
2021-06-10 00:20:23 +03:00
PasteButtons::paste_text(OUT, TEMP);
DISCARD_TEXT(TEMP)
2021-07-25 17:11:01 +03:00
WRITE("&nbsp;");
2021-07-26 02:34:51 +03:00
Localisation::italic(OUT, LD, I"Index.Elements.In.Double");
2021-06-10 00:20:23 +03:00
}
HTML_CLOSE("p");