Skip to content

Commit edaf898

Browse files
committed
not much done today
1 parent 921be44 commit edaf898

File tree

9 files changed

+230
-29
lines changed

9 files changed

+230
-29
lines changed

WriterSharp.PluginApi.V0/IPluginContext.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using WriterSharp.PluginApi.V0.Language;
2+
using WriterSharp.PluginApi.V0.Theming;
3+
using WriterSharp.PluginApi.V0.Utils;
24

35

46
namespace WriterSharp.PluginApi.V0
@@ -10,15 +12,25 @@ namespace WriterSharp.PluginApi.V0
1012
public interface IPluginContext
1113
{
1214

13-
// todo: code logger and file service interfaces
14-
ILogger Logger { get; set; }
15+
/// <summary>
16+
/// The global logger for WriterSharp.
17+
/// </summary>
18+
ILogger Log { get; set; }
1519

16-
IFileService FileService { get; set; }
20+
/// <summary>
21+
/// The file service for WriterSharp.
22+
/// </summary>
23+
IFileService Files { get; set; }
1724

1825
/// <summary>
1926
/// The global WriterSharp language manager.
2027
/// </summary>
21-
ILanguageManager LanguageManager { get; set; }
28+
ILanguageManager Languages { get; set; }
29+
30+
/// <summary>
31+
/// The global WriterSharp theme and flavor manager.
32+
/// </summary>
33+
IThemingManager Themes { get; set; }
2234

2335
}
2436

WriterSharp.PluginApi.V0/Language/ILanguageManager.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public interface ILanguageManager
1515
/// </summary>
1616
/// <param name="language">The language</param>
1717
/// <returns>A GUID that can be used to unregister this language later on</returns>
18-
public Guid RegisterLanguage(
18+
public Guid Register(
1919
LanguageDefinition language
2020
);
2121

@@ -24,7 +24,7 @@ LanguageDefinition language
2424
/// </summary>
2525
/// <param name="id">The language ID</param>
2626
/// <returns>The language</returns>
27-
public LanguageDefinition GetLanguage(
27+
public LanguageDefinition Get(
2828
string id
2929
);
3030

@@ -51,7 +51,7 @@ LanguageDefinition language
5151
/// </summary>
5252
/// <param name="fileExtension">One of the language's extensions</param>
5353
/// <returns>The language</returns>
54-
public LanguageDefinition GetLanguageByExtension(
54+
public LanguageDefinition GetByExtension(
5555
string fileExtension
5656
);
5757

@@ -60,7 +60,7 @@ string fileExtension
6060
/// </summary>
6161
/// <param name="grammar">One of the language's grammars</param>
6262
/// <returns>The language</returns>
63-
public LanguageDefinition GetLanguageByGrammar(
63+
public LanguageDefinition GetByGrammar(
6464
string grammar
6565
);
6666

@@ -69,7 +69,7 @@ string grammar
6969
/// </summary>
7070
/// <param name="associatedGuid">The GUID that was given at creation</param>
7171
/// <returns><c>true</c> if successful</returns>
72-
public bool UnregisterLanguage(
72+
public bool Unregister(
7373
Guid associatedGuid
7474
);
7575

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using System.IO;
2+
using System.Text.Json.Nodes;
3+
4+
5+
namespace WriterSharp.PluginApi.V0.Theming
6+
{
7+
8+
/// <summary>
9+
/// Blueprint for theme managers.
10+
/// </summary>
11+
public interface IThemingManager
12+
{
13+
14+
/// <summary>
15+
/// Registers a theme.
16+
/// </summary>
17+
/// <param name="theme">The theme to register.</param>
18+
void Register(Theme theme);
19+
20+
/// <summary>
21+
/// Sets a flavor from a theme.
22+
/// </summary>
23+
/// <param name="theme">The theme whose flavor to set.</param>
24+
void SetFlavor(Theme theme);
25+
26+
/// <summary>
27+
/// Sets a flavor from a theme file.
28+
/// </summary>
29+
/// <param name="themeFile">The file of the theme.</param>
30+
void SetFlavor(FileInfo themeFile);
31+
32+
/// <summary>
33+
/// Sets an editor theme from a theme.
34+
/// </summary>
35+
/// <param name="theme">The theme whose editor theme to set.</param>
36+
void SetTheme(Theme theme);
37+
38+
/// <summary>
39+
/// Sets an editor theme from a theme file.
40+
/// </summary>
41+
/// <param name="themeFile">The file of the theme.</param>
42+
void SetTheme(FileInfo themeFile);
43+
44+
/// <summary>
45+
/// Converts a theme to JSON format.
46+
/// </summary>
47+
/// <param name="theme">The theme to convert.</param>
48+
/// <returns>The root JSON node</returns>
49+
JsonObject ToJson(Theme theme);
50+
51+
}
52+
53+
}

WriterSharp.PluginApi.V0/Theming/Theme.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ public class Theme
1616
public required string Name { get; set; }
1717

1818
/// <summary>
19-
/// The colors of the theme (UI).
19+
/// The flavor (colors of the UI theme).
2020
/// </summary>
21-
public Dictionary<string, string> Colors { get; } = [];
21+
public Dictionary<string, string> Flavor { get; } = [];
2222

2323
/// <summary>
24-
/// The colors of the theme (syntax highlighting).
24+
/// The actual theme itself (colors of the editor).
2525
/// </summary>
2626
public Dictionary<string, TextFormatting> TokenColors { get; } = [];
2727

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
namespace WriterSharp.PluginApi.V0.Utils
2+
{
3+
4+
/// <summary>
5+
/// The severity of the async message.
6+
/// </summary>
7+
public enum AsyncMessageSeverity : byte
8+
{
9+
10+
/// <summary>
11+
/// A neutral message.
12+
/// </summary>
13+
NeutralMessage,
14+
15+
/// <summary>
16+
/// An info message.
17+
/// </summary>
18+
Info,
19+
20+
/// <summary>
21+
/// A success message.
22+
/// </summary>
23+
Success,
24+
25+
/// <summary>
26+
/// A warning message.
27+
/// </summary>
28+
Warning,
29+
30+
/// <summary>
31+
/// An error message.
32+
/// </summary>
33+
Error
34+
35+
}
36+
37+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using System.IO;
2+
3+
4+
namespace WriterSharp.PluginApi.V0.Utils
5+
{
6+
7+
/// <summary>
8+
/// Blueprint for file services.
9+
/// </summary>
10+
public interface IFileService
11+
{
12+
13+
/// <summary>
14+
/// <c>true</c> if the current file is saved.
15+
/// </summary>
16+
bool IsCurrentOpenSaved { get; }
17+
18+
/// <summary>
19+
/// Gets the current open file.
20+
/// Might fail if the current open file doesn't exist on disk
21+
/// yet.
22+
/// </summary>
23+
/// <exception cref="FileNotFoundException" />
24+
/// <returns>The file if one exists</returns>
25+
FileInfo GetCurrentOpen();
26+
27+
/// <summary>
28+
/// Tries to get the current open file.
29+
/// </summary>
30+
/// <param name="file">The file that's currently open or null if it doesn't exist on disk yet</param>
31+
/// <returns><c>true</c> if the current file exists on disk</returns>
32+
bool TryGetCurrentOpen(out FileInfo? file);
33+
34+
/// <summary>
35+
/// Opens a file.
36+
/// </summary>
37+
/// <param name="file">The file to open.</param>
38+
void Open(FileInfo file);
39+
40+
/// <summary>
41+
/// Saves the current file as another.
42+
/// </summary>
43+
/// <param name="newFile">The output file</param>
44+
void SaveAs(FileInfo newFile);
45+
46+
/// <summary>
47+
/// Saves and closes the current file.
48+
/// </summary>
49+
void Close();
50+
51+
/// <summary>
52+
/// Closes the current file.
53+
/// </summary>
54+
/// <param name="force">If <c>true</c>, will <strong>NOT</strong> save before closing.</param>
55+
void Close(bool force);
56+
57+
}
58+
59+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
namespace WriterSharp.PluginApi.V0.Utils
2+
{
3+
4+
/// <summary>
5+
/// Blueprint for loggers.
6+
/// </summary>
7+
public interface ILogger
8+
{
9+
10+
/// <summary>
11+
/// Logs an info message.
12+
/// </summary>
13+
/// <param name="message">The message to log.</param>
14+
void Info(string message);
15+
16+
/// <summary>
17+
/// Logs a warning message.
18+
/// </summary>
19+
/// <param name="message">The message to log.</param>
20+
void Warning(string message);
21+
22+
/// <summary>
23+
/// Logs an error message.
24+
/// </summary>
25+
/// <param name="message">The message to log.</param>
26+
void Error(string message);
27+
28+
/// <summary>
29+
/// Logs a success message.
30+
/// </summary>
31+
/// <param name="message">The message to log.</param>
32+
void Success(string message);
33+
34+
/// <summary>
35+
/// Logs a neutral message.
36+
/// </summary>
37+
/// <param name="message">The message to log.</param>
38+
void Message(string message);
39+
40+
}
41+
42+
}

WriterSharp.Tests/UnitTest1.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace WriterSharp.Tests
2+
{
3+
4+
public class UnitTest_Testing
5+
{
6+
7+
[Fact]
8+
public void ObjectEqualsToSelf() => Assert.Equal(1, 1.0);
9+
10+
[Fact]
11+
public void ObjectNotEqualsToSelf() => Assert.NotEqual(1, 1.001);
12+
13+
}
14+
15+
}

0 commit comments

Comments
 (0)