[education/rkward] /: Add option to offer code completion/hinting also in non-R-script files (importantly .Rmd)

Thomas Friedrichsmeier null at kde.org
Sat Jun 11 22:02:00 BST 2022


Git commit a88702fc6e329bb9f2b9121521afe197bb82c86e by Thomas Friedrichsmeier.
Committed on 11/06/2022 at 21:00.
Pushed by tfry into branch 'master'.

Add option to offer code completion/hinting also in non-R-script files (importantly .Rmd)

CCMAIL: stefan.roediger at b-tu.de

M  +1    -0    ChangeLog
M  +3    -0    rkward/settings/rksettingsmodulecommandeditor.cpp
M  +3    -1    rkward/settings/rksettingsmodulecommandeditor.h
M  +4    -2    rkward/windows/rkcommandeditorwindow.cpp

https://invent.kde.org/education/rkward/commit/a88702fc6e329bb9f2b9121521afe197bb82c86e

diff --git a/ChangeLog b/ChangeLog
index bc5b346d..1347a26c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+- Add option to offer code completion/hinting in all file types not just R scripts (e.g. in .Rmd files)
 - Fix zooming help/output pages with Ctrl+scroll wheel, when compiled with QWebEngine
 - Fix problem handling rkward:// links from dialogs on some sytems
 - Allow to select search provider, when searching for a term online
diff --git a/rkward/settings/rksettingsmodulecommandeditor.cpp b/rkward/settings/rksettingsmodulecommandeditor.cpp
index bc065ba5..14dbb064 100644
--- a/rkward/settings/rksettingsmodulecommandeditor.cpp
+++ b/rkward/settings/rksettingsmodulecommandeditor.cpp
@@ -91,6 +91,9 @@ RKCodeCompletionSettingsWidget::RKCodeCompletionSettingsWidget(QWidget *parent,
 			{{RObject::IncludeEnvirIfMasked, i18n("For masked objects, only")}, {RObject::IncludeEnvirIfNotGlobalEnv, i18n("For objects outside of <i>.GlobalEnv</i>, only")}, {RObject::IncludeEnvirIfNotGlobalEnv | RObject::IncludeEnvirForGlobalEnv, i18n("Always")}}
 		), this, RObject::IncludeEnvirIfNotGlobalEnv | RObject::IncludeEnvirForGlobalEnv | RObject::IncludeEnvirIfMasked);
 		form_layout->addRow (i18n ("Include environment for objects on the search path:"), completion_object_qualification_box);
+
+		auto completion_all_filetypes = settings->tabkey_invokes_completion.makeCheckbox(QString(), this);
+		form_layout->addRow(i18n("Offer completions in all file types (not just R scripts)"), completion_all_filetypes);
 	} else {
 		box_layout->addWidget(RKCommonFunctions::linkedWrappedLabel(i18n("<b>Note: </b>Additional (common) completion options are available at the <a href=\"rkward://settings/editor\">script editor settings</a>")));
 	}
diff --git a/rkward/settings/rksettingsmodulecommandeditor.h b/rkward/settings/rksettingsmodulecommandeditor.h
index 12c862c2..6eeed18e 100644
--- a/rkward/settings/rksettingsmodulecommandeditor.h
+++ b/rkward/settings/rksettingsmodulecommandeditor.h
@@ -45,6 +45,7 @@ public:
 	bool isEnabled(CompletionCategories cat) const { return completion_type_enabled[cat]; };
 	bool cursorNavigatesCompletions() const { return cursor_navigates_completions; };
 	bool tabKeyInvokesCompletion() const { return tabkey_invokes_completion; };
+	bool completionForAllFileTypes() const { return completion_all_filetypes; };
 private:
 friend class RKCodeCompletionSettingsWidget;
 friend class RKSettingsModuleConsole;
@@ -57,7 +58,8 @@ friend class RKSettingsModuleConsole;
 	RKConfigValue<bool> cursor_navigates_completions {"Cursor navigate completions", false};
 	RKConfigValue<int> completion_options {"Completion option flags", (int) RObject::IncludeEnvirIfMasked};
 	RKConfigGroup dummyoptions = RKConfigGroup(0, N_COMPLETION_CATEGORIES, completion_type_enabled);
-	RKConfigGroup group {"Completion", { &dummyoptions, &auto_completion_enabled, &auto_completion_min_chars, &auto_completion_timeout, &auto_completion_cursor_activated, &tabkey_invokes_completion, &cursor_navigates_completions, &completion_options }};
+	RKConfigValue<bool> completion_all_filetypes {"Completion all filetypes", true};
+	RKConfigGroup group {"Completion", { &dummyoptions, &auto_completion_enabled, &auto_completion_min_chars, &auto_completion_timeout, &auto_completion_cursor_activated, &tabkey_invokes_completion, &cursor_navigates_completions, &completion_options, &completion_all_filetypes }};
 };
 
 class RKCodeCompletionSettingsWidget : public RKSettingsModuleWidget {
diff --git a/rkward/windows/rkcommandeditorwindow.cpp b/rkward/windows/rkcommandeditorwindow.cpp
index afd30080..483b762c 100644
--- a/rkward/windows/rkcommandeditorwindow.cpp
+++ b/rkward/windows/rkcommandeditorwindow.cpp
@@ -266,12 +266,14 @@ RKCommandEditorWindow::RKCommandEditorWindow (QWidget *parent, const QUrl &_url,
 
 	if (use_r_highlighting) {
 		RKCommandHighlighter::setHighlighting (m_doc, RKCommandHighlighter::RScript);
+	} else {
+		RKCommandHighlighter::setHighlighting (m_doc, RKCommandHighlighter::Automatic);
+	}
+	if (use_r_highlighting || RKSettingsModuleCommandEditor::completionSettings()->completionForAllFileTypes()) {
 		if (flags & RKCommandEditorFlags::UseCodeHinting) {
 			new RKCompletionManager (m_view, RKSettingsModuleCommandEditor::completionSettings());
 			//hinter = new RKFunctionArgHinter (this, m_view);
 		}
-	} else {
-		RKCommandHighlighter::setHighlighting (m_doc, RKCommandHighlighter::Automatic);
 	}
 
 	smart_iface = qobject_cast<KTextEditor::MovingInterface*> (m_doc);


More information about the rkward-tracker mailing list