Skip to content

Commit 921be44

Browse files
committed
happy at last
jk, im still miserable
1 parent dfe2828 commit 921be44

File tree

7 files changed

+247
-6
lines changed

7 files changed

+247
-6
lines changed

WriterSharp.PluginApi.V0/Class1.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using WriterSharp.PluginApi.V0.Language;
2+
3+
4+
namespace WriterSharp.PluginApi.V0
5+
{
6+
7+
/// <summary>
8+
/// Blueprint for plugin contexts.
9+
/// </summary>
10+
public interface IPluginContext
11+
{
12+
13+
// todo: code logger and file service interfaces
14+
ILogger Logger { get; set; }
15+
16+
IFileService FileService { get; set; }
17+
18+
/// <summary>
19+
/// The global WriterSharp language manager.
20+
/// </summary>
21+
ILanguageManager LanguageManager { get; set; }
22+
23+
}
24+
25+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
namespace WriterSharp.PluginApi.V0
2+
{
3+
4+
/// <summary>
5+
/// Blueprint for a plugin.
6+
/// </summary>
7+
public interface IWriterSharpPlugin
8+
{
9+
10+
/// <summary>
11+
/// The name of the plugin.
12+
/// </summary>
13+
string Name { get; }
14+
15+
/// <summary>
16+
/// The version of the plugin.
17+
/// </summary>
18+
string Version { get; }
19+
20+
/// <summary>
21+
/// The author of the plugin.
22+
/// </summary>
23+
string Author { get; }
24+
25+
/// <summary>
26+
/// Initializes the current plugin.
27+
/// </summary>
28+
/// <param name="context">The context to give this plugin.</param>
29+
void Initialize(IPluginContext context);
30+
31+
/// <summary>
32+
/// Safely shuts down a plugin.
33+
/// </summary>
34+
void Shutdown();
35+
36+
}
37+
38+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
using System;
2+
3+
4+
namespace WriterSharp.PluginApi.V0.Language
5+
{
6+
7+
/// <summary>
8+
/// Blueprint for language managers.
9+
/// </summary>
10+
public interface ILanguageManager
11+
{
12+
13+
/// <summary>
14+
/// Registers a language into WriterSharp.
15+
/// </summary>
16+
/// <param name="language">The language</param>
17+
/// <returns>A GUID that can be used to unregister this language later on</returns>
18+
public Guid RegisterLanguage(
19+
LanguageDefinition language
20+
);
21+
22+
/// <summary>
23+
/// Retrieves a registered language.
24+
/// </summary>
25+
/// <param name="id">The language ID</param>
26+
/// <returns>The language</returns>
27+
public LanguageDefinition GetLanguage(
28+
string id
29+
);
30+
31+
/// <summary>
32+
/// Checks if a language is registered.
33+
/// </summary>
34+
/// <param name="id">The language ID</param>
35+
/// <returns>Is the language registered?</returns>
36+
public bool IsRegistered(
37+
string id
38+
);
39+
40+
/// <summary>
41+
/// Checks if a language is registered.
42+
/// </summary>
43+
/// <param name="language">The language</param>
44+
/// <returns>Is the language registered?</returns>
45+
public bool IsRegistered(
46+
LanguageDefinition language
47+
);
48+
49+
/// <summary>
50+
/// Retrieves a registered language by one of its extensions.
51+
/// </summary>
52+
/// <param name="fileExtension">One of the language's extensions</param>
53+
/// <returns>The language</returns>
54+
public LanguageDefinition GetLanguageByExtension(
55+
string fileExtension
56+
);
57+
58+
/// <summary>
59+
/// Retrieves a registered language by its grammar.
60+
/// </summary>
61+
/// <param name="grammar">One of the language's grammars</param>
62+
/// <returns>The language</returns>
63+
public LanguageDefinition GetLanguageByGrammar(
64+
string grammar
65+
);
66+
67+
/// <summary>
68+
/// Unregisters the language associated with the specified GUID.
69+
/// </summary>
70+
/// <param name="associatedGuid">The GUID that was given at creation</param>
71+
/// <returns><c>true</c> if successful</returns>
72+
public bool UnregisterLanguage(
73+
Guid associatedGuid
74+
);
75+
76+
}
77+
78+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
namespace WriterSharp.PluginApi.V0.Language
2+
{
3+
4+
/// <summary>
5+
/// Represents a language supported by WriterSharp (via the plugin).
6+
/// </summary>
7+
public class LanguageDefinition
8+
{
9+
10+
/// <summary>
11+
/// A unique ID to give this language.
12+
/// </summary>
13+
public required string Id { get; set; }
14+
15+
/// <summary>
16+
/// The file extensions that trigger this language.
17+
/// </summary>
18+
public string[] Extensions { get; set; } = [];
19+
20+
/// <summary>
21+
/// The path to a TextMate grammar.
22+
/// You may also pass an identifier for a default grammar if,
23+
/// instead of a path, you pass a string in the following format:
24+
/// <code>&lt;grammar-name&gt;</code>
25+
/// Examples:
26+
/// <list type="bullet"><c>path/to/grammar</c> (path)</list>
27+
/// <list type="bullet"><c>grammar</c> (path)</list>
28+
/// <list type="bullet"><c>&lt;grammar&gt;</c> (default grammar of name "grammar")</list>
29+
/// </summary>
30+
public string? TextMateGrammarPath { get; set; }
31+
32+
}
33+
34+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
namespace WriterSharp.PluginApi.V0.Theming
2+
{
3+
4+
/// <summary>
5+
/// Properties for the formatting of a token.
6+
/// </summary>
7+
public struct TextFormatting
8+
{
9+
10+
/// <summary>
11+
/// The background color of the token.
12+
/// </summary>
13+
public string? BackgroundColor { get; set; }
14+
15+
/// <summary>
16+
/// The foreground color of the token.
17+
/// </summary>
18+
public string TextColor { get; set; }
19+
20+
/// <summary>
21+
/// Whether the token should be <strong>bold</strong>.
22+
/// </summary>
23+
public bool Bold { get; set; }
24+
25+
/// <summary>
26+
/// Whether the token should be <i>italic</i>.
27+
/// </summary>
28+
public bool Italic { get; set; }
29+
30+
/// <summary>
31+
/// Whether the token should be <s>strikethrough</s>.
32+
/// </summary>
33+
public bool Strikethrough { get; set; }
34+
35+
/// <summary>
36+
/// Whether the token should be <u>underline</u>.
37+
/// </summary>
38+
public bool Underline { get; set; }
39+
40+
}
41+
42+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Collections.Generic;
2+
3+
4+
namespace WriterSharp.PluginApi.V0.Theming
5+
{
6+
7+
/// <summary>
8+
/// Represents a WriterSharp theme.
9+
/// </summary>
10+
public class Theme
11+
{
12+
13+
/// <summary>
14+
/// The name of the theme.
15+
/// </summary>
16+
public required string Name { get; set; }
17+
18+
/// <summary>
19+
/// The colors of the theme (UI).
20+
/// </summary>
21+
public Dictionary<string, string> Colors { get; } = [];
22+
23+
/// <summary>
24+
/// The colors of the theme (syntax highlighting).
25+
/// </summary>
26+
public Dictionary<string, TextFormatting> TokenColors { get; } = [];
27+
28+
}
29+
30+
}

0 commit comments

Comments
 (0)