mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:27:35 +00:00
HackStudio: Hookup git commit message detection and highlighting
This commit is contained in:
parent
974e36e7a9
commit
89592601b6
4 changed files with 24 additions and 6 deletions
|
@ -22,8 +22,9 @@ CodeDocument::CodeDocument(const String& file_path, Client* client)
|
||||||
: TextDocument(client)
|
: TextDocument(client)
|
||||||
, m_file_path(file_path)
|
, m_file_path(file_path)
|
||||||
{
|
{
|
||||||
m_language = language_from_file_extension(LexicalPath::extension(file_path));
|
auto lexical_path = LexicalPath(file_path);
|
||||||
m_language_name = language_name_from_file_extension(LexicalPath::extension(file_path));
|
m_language = language_from_file(lexical_path);
|
||||||
|
m_language_name = language_name_from_file(lexical_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeDocument::CodeDocument(Client* client)
|
CodeDocument::CodeDocument(Client* client)
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
#include <LibGUI/GMLAutocompleteProvider.h>
|
#include <LibGUI/GMLAutocompleteProvider.h>
|
||||||
#include <LibGUI/GMLSyntaxHighlighter.h>
|
#include <LibGUI/GMLSyntaxHighlighter.h>
|
||||||
|
#include <LibGUI/GitCommitSyntaxHighlighter.h>
|
||||||
#include <LibGUI/INISyntaxHighlighter.h>
|
#include <LibGUI/INISyntaxHighlighter.h>
|
||||||
#include <LibGUI/Label.h>
|
#include <LibGUI/Label.h>
|
||||||
#include <LibGUI/MessageBox.h>
|
#include <LibGUI/MessageBox.h>
|
||||||
|
@ -606,6 +607,9 @@ void Editor::set_syntax_highlighter_for(const CodeDocument& document)
|
||||||
case Language::CSS:
|
case Language::CSS:
|
||||||
set_syntax_highlighter(make<Web::CSS::SyntaxHighlighter>());
|
set_syntax_highlighter(make<Web::CSS::SyntaxHighlighter>());
|
||||||
break;
|
break;
|
||||||
|
case Language::GitCommit:
|
||||||
|
set_syntax_highlighter(make<GUI::GitCommitSyntaxHighlighter>());
|
||||||
|
break;
|
||||||
case Language::GML:
|
case Language::GML:
|
||||||
set_syntax_highlighter(make<GUI::GMLSyntaxHighlighter>());
|
set_syntax_highlighter(make<GUI::GMLSyntaxHighlighter>());
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -5,11 +5,16 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Language.h"
|
#include "Language.h"
|
||||||
|
#include <AK/LexicalPath.h>
|
||||||
|
|
||||||
namespace HackStudio {
|
namespace HackStudio {
|
||||||
|
|
||||||
Language language_from_file_extension(const String& extension)
|
Language language_from_file(const LexicalPath& file)
|
||||||
{
|
{
|
||||||
|
if (file.title() == "COMMIT_EDITMSG")
|
||||||
|
return Language::GitCommit;
|
||||||
|
|
||||||
|
auto extension = file.extension();
|
||||||
VERIFY(!extension.starts_with("."));
|
VERIFY(!extension.starts_with("."));
|
||||||
if (extension == "c" || extension == "cc" || extension == "cxx" || extension == "cpp" || extension == "c++"
|
if (extension == "c" || extension == "cc" || extension == "cxx" || extension == "cpp" || extension == "c++"
|
||||||
|| extension == "h" || extension == "hh" || extension == "hxx" || extension == "hpp" || extension == "h++")
|
|| extension == "h" || extension == "hh" || extension == "hxx" || extension == "hpp" || extension == "h++")
|
||||||
|
@ -40,12 +45,18 @@ Language language_from_name(const String& name)
|
||||||
return Language::JavaScript;
|
return Language::JavaScript;
|
||||||
if (name == "Shell")
|
if (name == "Shell")
|
||||||
return Language::Shell;
|
return Language::Shell;
|
||||||
|
if (name == "GitCommit")
|
||||||
|
return Language::GitCommit;
|
||||||
|
|
||||||
return Language::Unknown;
|
return Language::Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
String language_name_from_file_extension(const String& extension)
|
String language_name_from_file(const LexicalPath& file)
|
||||||
{
|
{
|
||||||
|
if (file.title() == "COMMIT_EDITMSG")
|
||||||
|
return "GitCommit";
|
||||||
|
|
||||||
|
auto extension = file.extension();
|
||||||
VERIFY(!extension.starts_with("."));
|
VERIFY(!extension.starts_with("."));
|
||||||
if (extension == "c" || extension == "cc" || extension == "cxx" || extension == "cpp" || extension == "c++"
|
if (extension == "c" || extension == "cc" || extension == "cxx" || extension == "cpp" || extension == "c++"
|
||||||
|| extension == "h" || extension == "hh" || extension == "hxx" || extension == "hpp" || extension == "h++")
|
|| extension == "h" || extension == "hh" || extension == "hxx" || extension == "hpp" || extension == "h++")
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/LexicalPath.h>
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
|
|
||||||
namespace HackStudio {
|
namespace HackStudio {
|
||||||
|
@ -15,14 +16,15 @@ enum class Language {
|
||||||
CSS,
|
CSS,
|
||||||
JavaScript,
|
JavaScript,
|
||||||
HTML,
|
HTML,
|
||||||
|
GitCommit,
|
||||||
GML,
|
GML,
|
||||||
Ini,
|
Ini,
|
||||||
Shell,
|
Shell,
|
||||||
SQL,
|
SQL,
|
||||||
};
|
};
|
||||||
|
|
||||||
Language language_from_file_extension(const String&);
|
Language language_from_file(const LexicalPath&);
|
||||||
Language language_from_name(const String&);
|
Language language_from_name(const String&);
|
||||||
String language_name_from_file_extension(const String&);
|
String language_name_from_file(const LexicalPath&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue