2019-05-03 00:29:04 +02:00
|
|
|
/*++
|
|
|
|
Copyright (c) Microsoft Corporation
|
|
|
|
Licensed under the MIT license.
|
|
|
|
|
|
|
|
Module Name:
|
|
|
|
- CascadiaSettings.hpp
|
|
|
|
|
|
|
|
Abstract:
|
|
|
|
- This class acts as the container for all app settings. It's composed of two
|
|
|
|
parts: Globals, which are app-wide settings, and Profiles, which contain
|
|
|
|
a set of settings that apply to a single instance of the terminal.
|
|
|
|
Also contains the logic for serializing and deserializing this object.
|
|
|
|
|
|
|
|
Author(s):
|
|
|
|
- Mike Griese - March 2019
|
|
|
|
|
|
|
|
--*/
|
|
|
|
#pragma once
|
|
|
|
#include <winrt/Microsoft.Terminal.TerminalControl.h>
|
|
|
|
#include "GlobalAppSettings.h"
|
|
|
|
#include "Profile.h"
|
|
|
|
|
2019-07-25 22:31:41 +02:00
|
|
|
static constexpr GUID AzureConnectionType = { 0xd9fcfdfa, 0xa479, 0x412c, { 0x83, 0xb7, 0xc5, 0x64, 0xe, 0x61, 0xcd, 0x62 } };
|
|
|
|
|
2019-05-03 00:29:04 +02:00
|
|
|
namespace TerminalApp
|
|
|
|
{
|
|
|
|
class CascadiaSettings;
|
|
|
|
};
|
|
|
|
|
|
|
|
class TerminalApp::CascadiaSettings final
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CascadiaSettings();
|
|
|
|
~CascadiaSettings();
|
|
|
|
|
|
|
|
static std::unique_ptr<CascadiaSettings> LoadAll(const bool saveOnLoad = true);
|
|
|
|
void SaveAll() const;
|
|
|
|
|
|
|
|
winrt::Microsoft::Terminal::Settings::TerminalSettings MakeSettings(std::optional<GUID> profileGuid) const;
|
|
|
|
|
|
|
|
GlobalAppSettings& GlobalSettings();
|
|
|
|
|
|
|
|
std::basic_string_view<Profile> GetProfiles() const noexcept;
|
|
|
|
|
|
|
|
winrt::TerminalApp::AppKeyBindings GetKeybindings() const noexcept;
|
|
|
|
|
2019-06-04 23:55:27 +02:00
|
|
|
Json::Value ToJson() const;
|
|
|
|
static std::unique_ptr<CascadiaSettings> FromJson(const Json::Value& json);
|
2019-05-03 00:29:04 +02:00
|
|
|
|
2019-08-09 00:02:34 +02:00
|
|
|
static std::wstring GetSettingsPath(const bool useRoamingPath = false);
|
2019-05-03 00:29:04 +02:00
|
|
|
|
|
|
|
const Profile* FindProfile(GUID profileGuid) const noexcept;
|
2019-05-23 22:09:35 +02:00
|
|
|
|
|
|
|
void CreateDefaults();
|
2019-06-11 22:27:09 +02:00
|
|
|
|
2019-05-03 00:29:04 +02:00
|
|
|
private:
|
|
|
|
GlobalAppSettings _globals;
|
|
|
|
std::vector<Profile> _profiles;
|
|
|
|
|
|
|
|
void _CreateDefaultKeybindings();
|
|
|
|
void _CreateDefaultSchemes();
|
|
|
|
void _CreateDefaultProfiles();
|
|
|
|
|
|
|
|
static bool _IsPackaged();
|
2019-06-18 20:52:34 +02:00
|
|
|
static void _WriteSettings(const std::string_view content);
|
|
|
|
static std::optional<std::string> _ReadSettings();
|
|
|
|
|
2019-05-24 00:02:32 +02:00
|
|
|
static bool _isPowerShellCoreInstalledInPath(const std::wstring_view programFileEnv, std::filesystem::path& cmdline);
|
|
|
|
static bool _isPowerShellCoreInstalled(std::filesystem::path& cmdline);
|
2019-06-07 23:12:32 +02:00
|
|
|
static void _AppendWslProfiles(std::vector<TerminalApp::Profile>& profileStorage);
|
2019-05-22 22:03:10 +02:00
|
|
|
static Profile _CreateDefaultProfile(const std::wstring_view name);
|
2019-05-03 00:29:04 +02:00
|
|
|
};
|