Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docker and automatic formatting for vscode #311

Merged
merged 2 commits into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 28 additions & 13 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
BasedOnStyle: Google
AccessModifierOffset: -4
AlignAfterOpenBracket: AlwaysBreak
AlignArrayOfStructures: Left
AlignOperands: AlignAfterOperator
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortFunctionsOnASingleLine: None
AllowShortLambdasOnASingleLine: All
BinPackArguments: false
BinPackParameters: false
BreakBeforeBraces: Custom
Expand All @@ -18,29 +24,38 @@ BraceWrapping:
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
ColumnLimit: "80"
Cpp11BracedListStyle: true
DerivePointerAlignment: "false"
IncludeBlocks: Preserve
IndentWidth: 4
IndentAccessModifiers: false
PointerAlignment: Right
ConstructorInitializerIndentWidth: 2
SortIncludes: "true"
QualifierAlignment: Right
IncludeBlocks: Regroup
IncludeCategories:
- Regex: ^<.*\.h.*>
- Regex: ^"[^/]+"
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: ^<.*
- Regex: ^".*"
Priority: 2
SortPriority: 3
CaseSensitive: false
- Regex: ^<.*\.h.*>
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: .*
Priority: 1
SortPriority: 0
- Regex: ^<(cassert|cctype|cerrno|cfenv|cfloat|cinttypes|climits|clocale|cmath|csetjmp|csignal|cstdarg|cstddef|cstdint|cstdio|cstdlib|cstring|ctime|cuchar|cwchar|cwctype)>$
Priority: 4
SortPriority: 5
CaseSensitive: false
- Regex: ^<.*
Priority: 4
SortPriority: 4
CaseSensitive: false
PointerAlignment: Right
ConstructorInitializerIndentWidth: 2
SortIncludes: "true"
QualifierAlignment: Right
5 changes: 1 addition & 4 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Checks: >
-google-readability-todo,
-misc-no-recursion,
-misc-unused-parameters,
-misc-non-private-member-variables-in-classes,
-modernize-avoid-c-arrays,
-modernize-use-trailing-return-type,
-readability-convert-member-functions-to-static,
Expand All @@ -25,8 +26,6 @@ Checks: >
WarningsAsErrors: "*"

CheckOptions:
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: true
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
value: true
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions
Expand All @@ -45,8 +44,6 @@ CheckOptions:
value: lower_case
- key: readability-identifier-naming.VariableCase
value: lower_case
- key: readability-identifier-naming.PublicMemberCase
value: lower_case
- key: readability-identifier-naming.ProtectedMemberCase
value: lower_case
- key: readability-identifier-naming.PrivateMemberCase
Expand Down
37 changes: 37 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
{
"name": "Existing Dockerfile",
"build": {
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerfile": "../Dockerfile"
},
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.cpptools-extension-pack",
"ms-vscode.cpptools",
"ms-vscode.cpptools-themes",
"twxs.cmake",
"ms-vscode.cmake-tools",
"ms-azuretools.vscode-docker",
"redhat.vscode-yaml",
"hbenl.vscode-test-explorer",
"llvm-vs-code-extensions.vscode-clangd",
"usernamehw.errorlens"
]
}
}
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "cat /etc/os-release",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ version.hpp
CMakeSettings.json
.cache
/.vs
/.vscode
/out
**/build
compile_commands.json
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"ms-azuretools.vscode-docker",
"ms-vscode-remote.remote-containers",
"ms-vscode-remote.remote-wsl"
]
}
30 changes: 30 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"files.associations": {
"source_location": "cpp",
"string_view": "cpp",
"chrono": "cpp",
"variant": "cpp"
},
"cmake.configureOnOpen": true,
"cmake.options.advanced": {
"ctest": {
"statusBarVisibility": "hidden"
},
"testPreset": {
"statusBarVisibility": "hidden"
},
"cpack": {
"statusBarVisibility": "hidden"
},
"packagePreset": {
"statusBarVisibility": "hidden"
},
"workflow": {
"statusBarVisibility": "hidden"
},
"workflowPreset": {
"statusBarVisibility": "hidden"
}
},
"cmake.copyCompileCommands": "${workspaceFolder}/compile_commands.json"
}
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM ubuntu:22.04

RUN apt-get update && DEBIAN_FRONTEND=noninteractive
RUN apt-get install -y g++ vim cmake git gdb wget libboost1.74-all-dev

ARG USERNAME=terminalpp
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME --shell /bin/bash \
#
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

USER $USERNAME

WORKDIR /workspace/$USERNAME
57 changes: 30 additions & 27 deletions include/terminalpp/algorithm/for_each_in_region.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#pragma once

#include <type_traits>
#include <utility>
#include "terminalpp/element.hpp"
#include "terminalpp/rectangle.hpp"

#include <type_traits>
#include <utility>

namespace terminalpp {

//* =========================================================================
Expand All @@ -23,34 +24,36 @@ namespace terminalpp {
/// when passed a const canvas).
//* =========================================================================
template <typename TwoDimensionalContainer, typename IndexedElementFunction>
void for_each_in_region(TwoDimensionalContainer &&container,
rectangle const &region,
IndexedElementFunction &&callable)
void for_each_in_region(
TwoDimensionalContainer &&container,
rectangle const &region,
IndexedElementFunction &&callable)
{
using x_coordinate = typename std::remove_cv<typename std::remove_reference<
TwoDimensionalContainer>::type>::type::size_type;

using y_coordinate = typename std::remove_cv<typename std::remove_reference<
decltype(container[std::declval<x_coordinate>()])>::type>::type::
size_type;

static_assert(
std::is_same<
terminalpp::element,
typename std::remove_cv<typename std::remove_reference<
decltype(container[std::declval<x_coordinate>()][std::declval<
y_coordinate>()])>::type>::type>::value,
"container[x][y] must yield an element");

for (auto row = region.origin_.y_;
row < region.origin_.y_ + region.size_.height_; ++row)
{
for (auto column = region.origin_.x_;
column < region.origin_.x_ + region.size_.width_; ++column)
using x_coordinate = typename std::remove_cv<
std::remove_reference_t<TwoDimensionalContainer>>::type::size_type;

using y_coordinate = typename std::remove_cv<std::remove_reference_t<
decltype(container[std::declval<x_coordinate>()])>>::type::size_type;

static_assert(
std::is_same_v<
terminalpp::element,
std::remove_cv_t<std::remove_reference_t<
decltype(container[std::declval<x_coordinate>()]
[std::declval<y_coordinate>()])>>>,
"container[x][y] must yield an element");

for (auto row = region.origin_.y_;
row < region.origin_.y_ + region.size_.height_;
++row)
{
callable(container[column][row], column, row);
for (auto column = region.origin_.x_;
column < region.origin_.x_ + region.size_.width_;
++column)
{
callable(container[column][row], column, row);
}
}
}
}

} // namespace terminalpp
12 changes: 6 additions & 6 deletions include/terminalpp/ansi/graphics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static constexpr auto blue_coefficient = 1;
// ==========================================================================
constexpr byte encode_high_components(byte red, byte green, byte blue)
{
return high_colour_offset + (red * red_coefficient)
return high_colour_offset + (red * red_coefficient)
+ (green * green_coefficient) + (blue * blue_coefficient);
}

Expand All @@ -70,23 +70,23 @@ constexpr byte encode_high_components(byte red, byte green, byte blue)
// ==========================================================================
constexpr byte high_red_component(byte value)
{
return (value - high_colour_offset) / red_coefficient;
return (value - high_colour_offset) / red_coefficient;
}

// ==========================================================================
/// \brief Extract the green component of a high colour value.
// ==========================================================================
constexpr byte high_green_component(byte value)
{
return ((value - high_colour_offset) % red_coefficient) / green_coefficient;
return ((value - high_colour_offset) % red_coefficient) / green_coefficient;
}

// ==========================================================================
/// \brief Extract the blue component of a high colour value.
// ==========================================================================
constexpr byte high_blue_component(byte value)
{
return (value - high_colour_offset) % green_coefficient;
return (value - high_colour_offset) % green_coefficient;
}

// "Greyscale" colour constants.
Expand All @@ -100,15 +100,15 @@ static constexpr byte greyscale_colour_offset = 232;
// ==========================================================================
constexpr byte encode_greyscale_component(byte grey)
{
return greyscale_colour_offset + grey;
return greyscale_colour_offset + grey;
}

// ==========================================================================
/// \brief Extract a greyscale value.
// ==========================================================================
constexpr byte greyscale_component(byte value)
{
return value - greyscale_colour_offset;
return value - greyscale_colour_offset;
}

} // namespace terminalpp::ansi::graphics
Loading
Loading