From 62aa1026ae92378ef8404b91a8a7d6b0623ac6d2 Mon Sep 17 00:00:00 2001 From: Graham Nelson Date: Tue, 11 Feb 2020 10:29:10 +0000 Subject: [PATCH] Support for settings files in Inform and Inbuild --- inbuild/Chapter 1/Main.w | 2 + inbuild/inbuild-module/Chapter 1/Shared CLI.w | 47 +++++++++++++------ inform7/Internal/HTML/xrefs.txt | 4 +- inform7/core-module/Chapter 1/Main Routine.w | 1 + 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/inbuild/Chapter 1/Main.w b/inbuild/Chapter 1/Main.w index eeeb96139..4fb7504a6 100644 --- a/inbuild/Chapter 1/Main.w +++ b/inbuild/Chapter 1/Main.w @@ -123,6 +123,8 @@ int main(int argc, char **argv) { if (LinkedLists::len(unsorted_nest_list) == 0) SharedCLI::add_nest( Pathnames::from_text(I"inform7/Internal"), INTERNAL_NEST_TAG); + + CommandLine::play_back_log(); SharedCLI::optioneering_complete(); inbuild_nest_list = SharedCLI::nest_list(); diff --git a/inbuild/inbuild-module/Chapter 1/Shared CLI.w b/inbuild/inbuild-module/Chapter 1/Shared CLI.w index 88fb5e5b9..cebc7f02e 100644 --- a/inbuild/inbuild-module/Chapter 1/Shared CLI.w +++ b/inbuild/inbuild-module/Chapter 1/Shared CLI.w @@ -123,6 +123,15 @@ int SharedCLI::set_I7_source(text_stream *loc) { int SharedCLI::set_I7_bundle(text_stream *loc) { if (Str::len(project_bundle_request) > 0) return FALSE; project_bundle_request = Str::duplicate(loc); + pathname *pathname_of_bundle = Pathnames::from_text(project_bundle_request); + pathname *materials = SharedCLI::pathname_of_materials(pathname_of_bundle); + TEMPORARY_TEXT(leaf); + WRITE_TO(leaf, "%s-settings.txt", INTOOL_NAME); + filename *expert_settings = Filenames::in_folder(materials, leaf); + LOG("Speculatively %f\n", expert_settings); + if (TextFiles::exists(expert_settings)) + CommandLine::also_read_file(expert_settings); + DISCARD_TEXT(leaf); return TRUE; } @@ -142,8 +151,6 @@ void SharedCLI::create_shared_project(void) { Filenames::in_folder( Pathnames::subfolder(pathname_of_bundle, I"Source"), I"story.ni"); - if (Str::includes(project_bundle_request, I"#2oetMiq9bqxoxY")) - Kits::request(I"BasicInformKit"); } if (Str::len(project_file_request) > 0) { filename_of_i7_source = Filenames::from_text(project_file_request); @@ -160,22 +167,10 @@ void SharedCLI::create_shared_project(void) { Projects::set_source_filename(shared_project, filename_of_i7_source); } -@ The materials folder sits alongside the project folder and has the same name, -but ending |.materials| instead of |.inform|. - @ = pathname *materials = NULL; if (pathname_of_bundle) { - TEMPORARY_TEXT(mf); - WRITE_TO(mf, "%S", Pathnames::directory_name(pathname_of_bundle)); - int i = Str::len(mf)-1; - while ((i>0) && (Str::get_at(mf, i) != '.')) i--; - if (i>0) { - Str::truncate(mf, i); - WRITE_TO(mf, ".materials"); - } - materials = Pathnames::subfolder(Pathnames::up(pathname_of_bundle), mf); - DISCARD_TEXT(mf); + materials = SharedCLI::pathname_of_materials(pathname_of_bundle); Pathnames::create_in_file_system(materials); } else if (filename_of_i7_source) { materials = Pathnames::from_text(I"inform.materials"); @@ -191,9 +186,29 @@ inform_project *SharedCLI::project(void) { return shared_project; } +@ The materials folder sits alongside the project folder and has the same name, +but ending |.materials| instead of |.inform|. + += +pathname *SharedCLI::pathname_of_materials(pathname *pathname_of_bundle) { + TEMPORARY_TEXT(mf); + WRITE_TO(mf, "%S", Pathnames::directory_name(pathname_of_bundle)); + int i = Str::len(mf)-1; + while ((i>0) && (Str::get_at(mf, i) != '.')) i--; + if (i>0) { + Str::truncate(mf, i); + WRITE_TO(mf, ".materials"); + } + pathname *materials = Pathnames::subfolder(Pathnames::up(pathname_of_bundle), mf); + DISCARD_TEXT(mf); + return materials; +} + @h Command line. We add the following switches: +@e INBUILD_CLSG + @e NEST_CLSW @e INTERNAL_CLSW @e EXTERNAL_CLSW @@ -204,6 +219,7 @@ We add the following switches: = void SharedCLI::declare_options(void) { + CommandLine::begin_group(INBUILD_CLSG); CommandLine::declare_switch(NEST_CLSW, L"nest", 2, L"add the nest at pathname X to the search list"); CommandLine::declare_switch(INTERNAL_CLSW, L"internal", 2, @@ -218,6 +234,7 @@ void SharedCLI::declare_options(void) { L"work within the Inform project X"); CommandLine::declare_switch(SOURCE_CLSW, L"source", 2, L"use file X as the Inform source text"); + CommandLine::end_group(); } void SharedCLI::option(int id, int val, text_stream *arg, void *state) { diff --git a/inform7/Internal/HTML/xrefs.txt b/inform7/Internal/HTML/xrefs.txt index df8e9cc58..f0d66cf81 100644 --- a/inform7/Internal/HTML/xrefs.txt +++ b/inform7/Internal/HTML/xrefs.txt @@ -4,7 +4,7 @@ PM_EnigmaticThey PM_EnigmaticPronoun PM_WordTooLong PM_TooMuchQuotedText PM_Unen PM_BadTitleSentence PM_HeadingStopsBeforeEndOfLine PM_HeadingOverLine HEADINGS _ doc14 "2.5" "2.5. Headings" PM_UnknownInternalTest PM_TestDoubleWith PM_TestCommandTooLong PM_TestContainsUndo PM_TestBadRequirements PM_TestDuplicate PM_TestMultiWord _ doc17 "2.8" "2.8. The TEST command" PM_BogusExtension _ doc19 "2.10" "2.10. Installing extensions" -PM_ExtMisidentifiedEnds PM_ExtInadequateVM PM_ExtMalformedVM PM_ExtMisidentified PM_ExtMiswordedBeginsHere PM_ExtVersionMalformed PM_IncludeExtQuoted _ doc20 "2.11" "2.11. Including extensions" +PM_ExtMisidentifiedEnds PM_ExtInadequateVM PM_ExtMalformedVM PM_ExtMiswordedBeginsHere PM_ExtVersionMalformed PM_IncludeExtQuoted _ doc20 "2.11" "2.11. Including extensions" OPTIONS PM_UnknownUseOption PM_UONotNumerical _ doc21 "2.12" "2.12. Use options" OPTIONSFILE _ doc22 "2.13" "2.13. Administering classroom use" STORYFILES PM_BadICLIdentifier _ doc23 "2.14" "2.14. Limits and the Settings panel" @@ -266,7 +266,7 @@ PM_MapPlacementDirection PM_MapPlacement PM_MapDirectionClue PM_MapHintUnknown P EPSMAP _ doc414 "25.19" "25.19. Producing an EPS format map" EXTENSIONS _ doc430 "27.1" "27.1. The status of extensions" SRULES _ doc431 "27.2" "27.2. The Standard Rules" -PM_ExtNoEndsHere PM_ExtNoBeginsHere PM_ExtMultipleEndsHere PM_ExtEndsWithoutBegins PM_ExtBeginsAfterEndsHere PM_ExtMultipleBeginsHere _ doc434 "27.5" "27.5. A simple example extension" +PM_ExtNoEndsHere PM_ExtNoBeginsHere PM_ExtMultipleEndsHere PM_ExtBeginsAfterEndsHere PM_ExtMultipleBeginsHere _ doc434 "27.5" "27.5. A simple example extension" PM_ExtNoVersion PM_ExtVersionTooLow phs_extcredits phs_compextcredits _ doc435 "27.6" "27.6. Version numbering" PM_UnequalHeadingInPlaceOf PM_HeadingInPlaceOfUnknown PM_HeadingInPlaceOfUnincluded _ doc438 "27.9" "27.9. Extensions can interact with other extensions" PM_ImplicationValueProperty PM_ImplicationCertain _ doc442 "27.13" "27.13. Implications" diff --git a/inform7/core-module/Chapter 1/Main Routine.w b/inform7/core-module/Chapter 1/Main Routine.w index 9cf29cfd1..bc6d6ff07 100644 --- a/inform7/core-module/Chapter 1/Main Routine.w +++ b/inform7/core-module/Chapter 1/Main Routine.w @@ -180,6 +180,7 @@ list is not exhaustive. LOG("Inform called as:"); for (int i=0; i