Skip to content

Commit

Permalink
Merge branch 'master' into jeremypw/fix-highlight-selection
Browse files Browse the repository at this point in the history
  • Loading branch information
zeebok authored Mar 9, 2025
2 parents e2e222a + c963475 commit d8c42c3
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 127 deletions.
99 changes: 52 additions & 47 deletions plugins/editorconfig/editorconfig.vala
Original file line number Diff line number Diff line change
Expand Up @@ -32,60 +32,65 @@ public class Scratch.Plugins.EditorConfigPlugin: Peas.ExtensionBase, Peas.Activa
});

plugins.hook_document.connect ((d) => {
// Ensure use global settings by default
format_bar.tab_style_set_by_editor_config = false;
format_bar.tab_width_set_by_editor_config = false;
format_bar.set_document (d);
update_config.begin (d);
});

Scratch.Widgets.SourceView view = d.source_view;
File file = d.file;
}

if (file == null || !file.query_exists ()) {
return;
}
private async void update_config (Scratch.Services.Document d) {
// Ensure use global settings by default
format_bar.tab_style_set_by_editor_config = false;
format_bar.tab_width_set_by_editor_config = false;
format_bar.set_document (d);

var handle = new EditorConfig.Handle ();
handle.set_conf_file_name (".editorconfig");
if (handle.parse (file.get_path ()) != 0) {
return;
}
Scratch.Widgets.SourceView view = d.source_view;
File file = d.file;

for (int i = 0; i < handle.get_name_value_count (); i++) {
string name, val;
handle.get_name_value (i, out name, out val);
/* These are all properties (https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties) */
switch (name) {
case "indent_style":
format_bar.tab_style_set_by_editor_config = true;
var use_spaces = (val != "tab");
format_bar.set_insert_spaces_instead_of_tabs (use_spaces);
break;
case "indent_size":
case "tab_width":
format_bar.tab_width_set_by_editor_config = true;
var indent_width = (int.parse (val)).clamp (2, 16);
format_bar.set_tab_width (indent_width);
break;
case "end_of_line":
break;
case "charset":
break;
case "trim_trailing_whitespace":
break;
case "insert_final_newline":
break;
case "max_line_length":
view.right_margin_position = int.parse (val);
break;
default:
warning ("unrecognised name/value %s/%s", name, val);
break;
}
if (file == null || !file.query_exists ()) {
return;
}

var handle = new EditorConfig.Handle ();
handle.set_conf_file_name (".editorconfig");
if (handle.parse (file.get_path ()) != 0) {
return;
}

for (int i = 0; i < handle.get_name_value_count (); i++) {
string name, val;
handle.get_name_value (i, out name, out val);
/* These are all properties (https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties) */
switch (name) {
case "indent_style":
format_bar.tab_style_set_by_editor_config = true;
var use_spaces = (val != "tab");
format_bar.set_insert_spaces_instead_of_tabs (use_spaces);
break;
case "indent_size":
case "tab_width":
format_bar.tab_width_set_by_editor_config = true;
var indent_width = (int.parse (val)).clamp (2, 16);
format_bar.set_tab_width (indent_width);
break;
case "end_of_line":
break;
case "charset":
break;
case "trim_trailing_whitespace":
break;
case "insert_final_newline":
break;
case "max_line_length":
view.right_margin_position = int.parse (val);
break;
default:
warning ("unrecognised name/value %s/%s", name, val);
break;
}
});
}
}

public void deactivate () { }
public void deactivate () { debug ("Editor config deactivate");}
}

[ModuleInit]
Expand Down
10 changes: 5 additions & 5 deletions po/ca.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ msgstr ""
"Project-Id-Version: scratch\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-03-07 05:04+0000\n"
"PO-Revision-Date: 2025-03-03 20:15+0000\n"
"PO-Revision-Date: 2025-03-08 08:16+0000\n"
"Last-Translator: David M <[email protected]>\n"
"Language-Team: Catalan <https://l10n.elementary.io/projects/code/code/ca/>\n"
"Language: ca\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.9.2\n"
"X-Generator: Weblate 5.10.2\n"
"X-Launchpad-Export-Date: 2017-05-03 06:01+0000\n"

#: src/Application.vala:41 src/Widgets/DocumentView.vala:99
Expand Down Expand Up @@ -126,7 +126,7 @@ msgstr "_Cancel·la"
#: src/Utils.vala:212
#, c-format
msgid "Show '%s' with default app"
msgstr ""
msgstr "Mostra %s amb l'aplicació per defecte"

#: src/Dialogs/GlobalSearchDialog.vala:69
#, c-format
Expand Down Expand Up @@ -624,13 +624,13 @@ msgstr "Desa el document en un altre lloc"

#: src/Services/MonitoredRepository.vala:213
msgid "An error occurred while checking out the requested branch"
msgstr ""
msgstr "Hi ha hagut un error en revisar la branca demanada"

#. /TRANSLATORS "%.8s" is a placeholder for the first 8 characters of a commit reference
#: src/Services/MonitoredRepository.vala:261
#, c-format
msgid "%.8s (detached)"
msgstr ""
msgstr "%.8s (separat)"

#: src/Services/TemplateManager.vala:198
msgid "Templates"
Expand Down
13 changes: 7 additions & 6 deletions po/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ msgstr ""
"Project-Id-Version: scratch\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-03-07 05:04+0000\n"
"PO-Revision-Date: 2025-03-06 14:08+0000\n"
"PO-Revision-Date: 2025-03-09 08:41+0000\n"
"Last-Translator: Uwe S <[email protected]>\n"
"Language-Team: German <https://l10n.elementary.io/projects/code/code/de/>\n"
"Language-Team: German <https://l10n.elementaryos.org/projects/code/code/de/>"
"\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.9.2\n"
"X-Generator: Weblate 5.10.2\n"
"X-Launchpad-Export-Date: 2017-05-03 06:01+0000\n"

#: src/Application.vala:41 src/Widgets/DocumentView.vala:99
Expand Down Expand Up @@ -126,7 +127,7 @@ msgstr "_Abbrechen"
#: src/Utils.vala:212
#, c-format
msgid "Show '%s' with default app"
msgstr ""
msgstr "»%s« mit Standardanwendung anzeigen"

#: src/Dialogs/GlobalSearchDialog.vala:69
#, c-format
Expand Down Expand Up @@ -634,13 +635,13 @@ msgstr "Dokument an anderem Ort speichern"

#: src/Services/MonitoredRepository.vala:213
msgid "An error occurred while checking out the requested branch"
msgstr ""
msgstr "Beim Auschecken des angeforderten Branchs ist ein Fehler aufgetreten"

#. /TRANSLATORS "%.8s" is a placeholder for the first 8 characters of a commit reference
#: src/Services/MonitoredRepository.vala:261
#, c-format
msgid "%.8s (detached)"
msgstr ""
msgstr "%.8s (losgelöst)"

#: src/Services/TemplateManager.vala:198
msgid "Templates"
Expand Down
34 changes: 11 additions & 23 deletions po/en_GB.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ msgstr ""
"Project-Id-Version: scratch\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-03-07 05:04+0000\n"
"PO-Revision-Date: 2025-02-12 00:44+0000\n"
"Last-Translator: Jeremy Wootten <jeremywootten@gmail.com>\n"
"PO-Revision-Date: 2025-03-08 08:16+0000\n"
"Last-Translator: David Hewitt <davidmhewitt@gmail.com>\n"
"Language-Team: English (United Kingdom) <https://l10n.elementary.io/projects/"
"code/code/en_GB/>\n"
"Language: en_GB\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.9.2\n"
"X-Generator: Weblate 5.10.2\n"
"X-Launchpad-Export-Date: 2017-05-03 06:04+0000\n"

#: src/Application.vala:41 src/Widgets/DocumentView.vala:99
Expand Down Expand Up @@ -127,7 +127,7 @@ msgstr "_Cancel"
#: src/Utils.vala:212
#, c-format
msgid "Show '%s' with default app"
msgstr ""
msgstr "Show '%s' with default app"

#: src/Dialogs/GlobalSearchDialog.vala:69
#, c-format
Expand Down Expand Up @@ -294,28 +294,22 @@ msgid "Restore Anyway"
msgstr "Restore Anyway"

#: src/Dialogs/CloseProjectsConfirmationDialog.vala:40
#, fuzzy
#| msgid "This folder is the parent of an open project"
msgid "This folder is the parent of an open project"
msgid_plural "This folder is the parent of open projects"
msgstr[0] "This folder is the parent of an open project"
msgstr[1] "This folder is the parent of an open project"
msgstr[1] "This folder is the parent of open projects"

#: src/Dialogs/CloseProjectsConfirmationDialog.vala:46
#, fuzzy
#| msgid "Opening this folder will close the child project"
msgid "Opening this folder will close the child project"
msgid_plural "Opening this folder will close all child projects"
msgstr[0] "Opening this folder will close the child project"
msgstr[1] "Opening this folder will close the child project"
msgstr[1] "Opening this folder will close all child projects"

#: src/Dialogs/CloseProjectsConfirmationDialog.vala:52
#, fuzzy
#| msgid "Close Child Project"
msgid "Close Child Project"
msgid_plural "Close Child Projects"
msgstr[0] "Close Child Project"
msgstr[1] "Close Child Project"
msgstr[1] "Close Child Projects"

#: src/Dialogs/CloseProjectsConfirmationDialog.vala:57
msgid "This folder is a child of an open project"
Expand All @@ -339,13 +333,7 @@ msgstr "There are uncommitted changes in the current branch"

#. /TRANSLATORS '%s' is a placeholder for the name of the branch to be checked out
#: src/Dialogs/OverwriteUncommittedConfirmationDialog.vala:42
#, fuzzy, c-format
#| msgid ""
#| "Uncommitted changes will be permanently lost if <b>'%s'</b> is checked "
#| "out now.\n"
#| "\n"
#| "<i>It is recommended that uncommitted changes are stashed, committed, or "
#| "reverted before proceeding </i>"
#, c-format
msgid ""
"Uncommitted changes will be permanently lost if <b>'%s'</b> is checked out "
"now.\n"
Expand All @@ -357,7 +345,7 @@ msgstr ""
"now.\n"
"\n"
"<i>It is recommended that uncommitted changes are stashed, committed, or "
"reverted before proceeding </i>"
"reverted before proceeding.</i>"

#: src/Dialogs/OverwriteUncommittedConfirmationDialog.vala:44
msgid "Do not Checkout"
Expand Down Expand Up @@ -631,13 +619,13 @@ msgstr "Save Document elsewhere"

#: src/Services/MonitoredRepository.vala:213
msgid "An error occurred while checking out the requested branch"
msgstr ""
msgstr "An error occurred while checking out the requested branch"

#. /TRANSLATORS "%.8s" is a placeholder for the first 8 characters of a commit reference
#: src/Services/MonitoredRepository.vala:261
#, c-format
msgid "%.8s (detached)"
msgstr ""
msgstr "%.8s (detached)"

#: src/Services/TemplateManager.vala:198
msgid "Templates"
Expand Down
10 changes: 5 additions & 5 deletions po/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ msgstr ""
"Project-Id-Version: scratch\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-03-07 05:04+0000\n"
"PO-Revision-Date: 2025-03-02 19:26+0000\n"
"PO-Revision-Date: 2025-03-08 08:16+0000\n"
"Last-Translator: Italo Felipe Capasso Ballesteros <[email protected]>\n"
"Language-Team: Spanish <https://l10n.elementary.io/projects/code/code/es/>\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.9.2\n"
"X-Generator: Weblate 5.10.2\n"
"X-Launchpad-Export-Date: 2017-05-03 06:03+0000\n"

#: src/Application.vala:41 src/Widgets/DocumentView.vala:99
Expand Down Expand Up @@ -126,7 +126,7 @@ msgstr "_Cancelar"
#: src/Utils.vala:212
#, c-format
msgid "Show '%s' with default app"
msgstr ""
msgstr "Mostrar '%s' con la aplicación predeterminada"

#: src/Dialogs/GlobalSearchDialog.vala:69
#, c-format
Expand Down Expand Up @@ -626,13 +626,13 @@ msgstr "Guardar el documento en otro lugar"

#: src/Services/MonitoredRepository.vala:213
msgid "An error occurred while checking out the requested branch"
msgstr ""
msgstr "Se ha producido un error al tratar de descargar la rama solicitada"

#. /TRANSLATORS "%.8s" is a placeholder for the first 8 characters of a commit reference
#: src/Services/MonitoredRepository.vala:261
#, c-format
msgid "%.8s (detached)"
msgstr ""
msgstr "%.8s (desconectado)"

#: src/Services/TemplateManager.vala:198
msgid "Templates"
Expand Down
10 changes: 5 additions & 5 deletions po/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ msgstr ""
"Project-Id-Version: scratch\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-03-07 05:04+0000\n"
"PO-Revision-Date: 2025-03-05 09:35+0000\n"
"PO-Revision-Date: 2025-03-08 08:16+0000\n"
"Last-Translator: Nathan <[email protected]>\n"
"Language-Team: French <https://l10n.elementary.io/projects/code/code/fr/>\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 5.9.2\n"
"X-Generator: Weblate 5.10.2\n"
"X-Launchpad-Export-Date: 2017-05-03 06:01+0000\n"

#: src/Application.vala:41 src/Widgets/DocumentView.vala:99
Expand Down Expand Up @@ -126,7 +126,7 @@ msgstr "_Annuler"
#: src/Utils.vala:212
#, c-format
msgid "Show '%s' with default app"
msgstr ""
msgstr "Afficher « %s » avec l'application par défaut"

#: src/Dialogs/GlobalSearchDialog.vala:69
#, c-format
Expand Down Expand Up @@ -630,13 +630,13 @@ msgstr "Enregistrer le document ailleurs"

#: src/Services/MonitoredRepository.vala:213
msgid "An error occurred while checking out the requested branch"
msgstr ""
msgstr "Une erreur s'est produite lors de l'extraction de la branche demandée"

#. /TRANSLATORS "%.8s" is a placeholder for the first 8 characters of a commit reference
#: src/Services/MonitoredRepository.vala:261
#, c-format
msgid "%.8s (detached)"
msgstr ""
msgstr "%.8s (détachée)"

#: src/Services/TemplateManager.vala:198
msgid "Templates"
Expand Down
Loading

0 comments on commit d8c42c3

Please sign in to comment.