terminal/src/cascadia/TerminalApp/Profile.h
fghzxm 6088134832 Improve startingDirectory functionality (#604)
* Improve `startingDirectory` functionality

This commit adds the `startingDirectory` property to the default-created
`cmd` and `powershell` profiles, with the default value
`%HOMEDRIVE%%HOMEPATH%`.

Signed-off-by: Fred Miller <fghzxm@outlook.com>

* Use %USERPROFILE% to replace %HOMEDRIVE%%HOMEPATH%

This commit changes `%USERPROFILE%` in the default profiles to
`%HOMEDRIVE%%HOMEPATH%`.

https://stackoverflow.com/posts/36392591/revisions says `%USERPROFILE%`
is better than `%HOMEDRIVE%%HOMEPATH%`, so changed it.

Signed-off-by: Fred Miller <fghzxm@outlook.com>

* Improve `startingDirectory` functionality

This commit adds the `startingDirectory` property to the default-created
`cmd` and `powershell` profiles, with the default value
`%HOMEDRIVE%%HOMEPATH%`.

Signed-off-by: Fred Miller <fghzxm@outlook.com>

* Use %USERPROFILE% to replace %HOMEDRIVE%%HOMEPATH%

This commit changes `%USERPROFILE%` in the default profiles to
`%HOMEDRIVE%%HOMEPATH%`.

https://stackoverflow.com/posts/36392591/revisions says `%USERPROFILE%`
is better than `%HOMEDRIVE%%HOMEPATH%`, so changed it.

Signed-off-by: Fred Miller <fghzxm@outlook.com>

* Consolidate constant

Refer to the externally defined constant in code.

Signed-off-by: Fred Miller <fghzxm@outlook.com>
2019-05-11 00:02:28 -07:00

90 lines
2.8 KiB
C++

/*++
Copyright (c) Microsoft Corporation
Licensed under the MIT license.
Module Name:
- Profile.hpp
Abstract:
- A profile acts as a single set of terminal settings. Many tabs or panes could
exist side-by-side with different profiles simultaneously.
Author(s):
- Mike Griese - March 2019
--*/
#pragma once
#include "ColorScheme.h"
namespace TerminalApp
{
class Profile;
};
class TerminalApp::Profile final
{
public:
Profile();
~Profile();
winrt::Microsoft::Terminal::Settings::TerminalSettings CreateTerminalSettings(const std::vector<::TerminalApp::ColorScheme>& schemes) const;
winrt::Windows::Data::Json::JsonObject ToJson() const;
static Profile FromJson(winrt::Windows::Data::Json::JsonObject json);
GUID GetGuid() const noexcept;
std::wstring_view GetName() const noexcept;
void SetFontFace(std::wstring fontFace) noexcept;
void SetColorScheme(std::optional<std::wstring> schemeName) noexcept;
void SetAcrylicOpacity(double opacity) noexcept;
void SetCommandline(std::wstring cmdline) noexcept;
void SetStartingDirectory(std::wstring startingDirectory) noexcept;
void SetName(std::wstring name) noexcept;
void SetUseAcrylic(bool useAcrylic) noexcept;
void SetDefaultForeground(COLORREF defaultForeground) noexcept;
void SetDefaultBackground(COLORREF defaultBackground) noexcept;
bool HasIcon() const noexcept;
std::wstring_view GetIconPath() const noexcept;
bool GetCloseOnExit() const noexcept;
private:
static std::wstring EvaluateStartingDirectory(const std::wstring& directory);
static winrt::Microsoft::Terminal::Settings::ScrollbarState ParseScrollbarState(const std::wstring& scrollbarState);
static winrt::Microsoft::Terminal::Settings::CursorStyle _ParseCursorShape(const std::wstring& cursorShapeString);
static std::wstring _SerializeCursorStyle(const winrt::Microsoft::Terminal::Settings::CursorStyle cursorShape);
GUID _guid;
std::wstring _name;
// If this is set, then our colors should come from the associated color scheme
std::optional<std::wstring> _schemeName;
std::optional<uint32_t> _defaultForeground;
std::optional<uint32_t> _defaultBackground;
std::array<uint32_t, COLOR_TABLE_SIZE> _colorTable;
int32_t _historySize;
bool _snapOnInput;
uint32_t _cursorColor;
uint32_t _cursorHeight;
winrt::Microsoft::Terminal::Settings::CursorStyle _cursorShape;
std::wstring _commandline;
std::wstring _fontFace;
std::optional<std::wstring> _startingDirectory;
int32_t _fontSize;
double _acrylicTransparency;
bool _useAcrylic;
std::optional<std::wstring> _scrollbarState;
bool _closeOnExit;
std::wstring _padding;
std::optional<std::wstring> _icon;
};