-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from extio1/dev
Model and Controller MVP done
- Loading branch information
Showing
66 changed files
with
5,401 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
BasedOnStyle: Google | ||
IndentWidth: 4 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: build | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- 'release' | ||
- 'dev' | ||
|
||
jobs: | ||
download-dependencies: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- run: mkdir install-artifacts | ||
- name: Download dependencies | ||
run: | | ||
wget https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.gz | ||
- name: Save artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: dependencies-artifact | ||
path: boost_1_80_0.tar.gz | ||
|
||
build: | ||
needs: [download-dependencies] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: dependencies-artifact | ||
|
||
- name: Install Boost | ||
run: | | ||
tar -xzf boost_1_80_0.tar.gz | ||
cd boost_1_80_0 | ||
./bootstrap.sh --with-libraries=serialization | ||
sudo ./b2 install | ||
- name: Build project | ||
run: | | ||
mkdir build | ||
cmake -Bbuild | ||
cmake --build build | ||
- name: Save artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: build-artifacts | ||
path: build | ||
|
||
test: | ||
needs: [build, download-dependencies] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: build-artifacts | ||
path: build | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: dependencies-artifact | ||
|
||
- name: Install Boost | ||
run: | | ||
tar -xzf boost_1_80_0.tar.gz | ||
cd boost_1_80_0 | ||
./bootstrap.sh --with-libraries=serialization | ||
sudo ./b2 install | ||
- name: Add lanch permissions for text executables | ||
run: | | ||
chmod +x build/test/model/* | ||
chmod +x build/test/controller/* | ||
- name: Run tests | ||
run: GTEST_COLOR=1 ctest -V --test-dir build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{ | ||
"files.associations": { | ||
"any": "cpp", | ||
"array": "cpp", | ||
"atomic": "cpp", | ||
"bit": "cpp", | ||
"*.tcc": "cpp", | ||
"bitset": "cpp", | ||
"cctype": "cpp", | ||
"chrono": "cpp", | ||
"clocale": "cpp", | ||
"cmath": "cpp", | ||
"compare": "cpp", | ||
"concepts": "cpp", | ||
"condition_variable": "cpp", | ||
"cstdarg": "cpp", | ||
"cstddef": "cpp", | ||
"cstdint": "cpp", | ||
"cstdio": "cpp", | ||
"cstdlib": "cpp", | ||
"cstring": "cpp", | ||
"ctime": "cpp", | ||
"cwchar": "cpp", | ||
"cwctype": "cpp", | ||
"deque": "cpp", | ||
"forward_list": "cpp", | ||
"list": "cpp", | ||
"map": "cpp", | ||
"set": "cpp", | ||
"string": "cpp", | ||
"unordered_map": "cpp", | ||
"unordered_set": "cpp", | ||
"vector": "cpp", | ||
"exception": "cpp", | ||
"algorithm": "cpp", | ||
"functional": "cpp", | ||
"iterator": "cpp", | ||
"memory": "cpp", | ||
"memory_resource": "cpp", | ||
"numeric": "cpp", | ||
"optional": "cpp", | ||
"random": "cpp", | ||
"ratio": "cpp", | ||
"string_view": "cpp", | ||
"system_error": "cpp", | ||
"tuple": "cpp", | ||
"type_traits": "cpp", | ||
"utility": "cpp", | ||
"fstream": "cpp", | ||
"initializer_list": "cpp", | ||
"iomanip": "cpp", | ||
"iosfwd": "cpp", | ||
"iostream": "cpp", | ||
"istream": "cpp", | ||
"limits": "cpp", | ||
"mutex": "cpp", | ||
"new": "cpp", | ||
"numbers": "cpp", | ||
"ostream": "cpp", | ||
"semaphore": "cpp", | ||
"span": "cpp", | ||
"sstream": "cpp", | ||
"stdexcept": "cpp", | ||
"stop_token": "cpp", | ||
"streambuf": "cpp", | ||
"thread": "cpp", | ||
"cinttypes": "cpp", | ||
"typeinfo": "cpp", | ||
"variant": "cpp" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
cmake_minimum_required(VERSION 3.14) | ||
project(text_editor_project) | ||
|
||
set(target text_editor) | ||
|
||
# GoogleTest requires at least C++14 | ||
set(CMAKE_CXX_STANDARD 14) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
set(include_dir ${CMAKE_CURRENT_SOURCE_DIR}/include) | ||
|
||
add_subdirectory(src) | ||
enable_testing() | ||
add_subdirectory(test) | ||
|
||
add_executable(${target} main.cpp) | ||
target_include_directories(${target} PUBLIC ${include_dir}) | ||
|
||
if(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
target_compile_options(${target} PRIVATE -Wall -Wextra -Wconversion -pedantic -g) | ||
endif() | ||
|
||
target_link_libraries(${target} executor document point compositor) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Installation | ||
|
||
```console | ||
mkdir build; cd build | ||
cmake .. | ||
cmake --build . | ||
``` | ||
|
||
# Usage | ||
As result of the build executables are available (in `build`): | ||
1. `text_editor` - executable with entry point in main.c | ||
2. `test/model/model_test` - google tests for model |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
for file in `find ../include -type f | grep -i -E '\.(cpp|h|c|hpp)$'`; do | ||
clang-format -style=file -i ${file} | ||
echo ${file} ": formatted" | ||
done | ||
|
||
for file in `find ../src -type f | grep -i -E '\.(cpp|h|c|hpp)$'`; do | ||
clang-format -style=file -i ${file} | ||
echo ${file} ": formatted" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
for file in `git diff --staged --name-only | grep -i -E '\.(cpp|h|c|hpp)$'`; do | ||
clang-format -style=file -i ${file} | ||
git add ${file} | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#ifndef TEXT_EDITOR_COMPOSITOR_H_ | ||
#define TEXT_EDITOR_COMPOSITOR_H_ | ||
|
||
#include <iostream> | ||
#include <boost/serialization/export.hpp> | ||
#include <boost/serialization/access.hpp> | ||
|
||
#include "document/document.h" | ||
|
||
class Compositor { | ||
public: | ||
enum Alignment { LEFT, CENTER, RIGHT, JUSTIFIED }; | ||
|
||
Compositor() { | ||
document = nullptr; | ||
this->topIndent = 5; | ||
this->bottomIndent = 10; | ||
this->leftIndent = 3; | ||
this->rightIndent = 6; | ||
this->alignment = LEFT; | ||
this->lineSpacing = 3; | ||
} | ||
|
||
Compositor(int topIndent, int bottomIndent, int leftIndent, | ||
int rightIndent, Alignment alignment, | ||
int lineSpacing) { | ||
document = nullptr; | ||
this->topIndent = topIndent; | ||
this->bottomIndent = bottomIndent; | ||
this->leftIndent = leftIndent; | ||
this->rightIndent = rightIndent; | ||
this->alignment = alignment; | ||
this->lineSpacing = lineSpacing; | ||
} | ||
|
||
virtual ~Compositor() = default; | ||
|
||
void SetDocument(Document* document); | ||
|
||
virtual void Compose() = 0; | ||
|
||
void SetTopIndent(int value); | ||
void SetBottomIndent(int value); | ||
void SetLeftIndent(int value); | ||
void SetRightIndent(int value); | ||
void SetAlignment(Alignment value); | ||
void SetLineSpacing(int value); | ||
|
||
protected: | ||
Document* document; | ||
|
||
int topIndent; | ||
int bottomIndent; | ||
int leftIndent; | ||
int rightIndent; | ||
Alignment alignment; | ||
int lineSpacing; | ||
|
||
private: | ||
friend class boost::serialization::access; | ||
template<class Archive> | ||
void serialize(Archive &ar, const unsigned int version) | ||
{ | ||
std::cout << "0 Compositor\n"; | ||
ar & document; | ||
ar & topIndent & bottomIndent & leftIndent; | ||
ar & rightIndent & alignment & lineSpacing; | ||
std::cout << "1 Compositor\n"; | ||
} | ||
|
||
}; | ||
BOOST_CLASS_EXPORT_KEY(Compositor) | ||
|
||
#endif // TEXT_EDITOR_COMPOSITOR_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#ifndef TEXT_EDITOR_SIMPLECOMPOSITOR_H_ | ||
#define TEXT_EDITOR_SIMPLECOMPOSITOR_H_ | ||
|
||
#include <iostream> | ||
#include <boost/serialization/export.hpp> | ||
#include <boost/serialization/access.hpp> | ||
#include <boost/serialization/base_object.hpp> | ||
|
||
#include "compositor/compositor.h" | ||
#include "document/document.h" | ||
|
||
class SimpleCompositor : public Compositor { | ||
public: | ||
explicit SimpleCompositor() | ||
: Compositor(5, 10, 3, 6, | ||
LEFT, 5) {} | ||
|
||
explicit SimpleCompositor(int topIndent, int bottomIndent, | ||
int leftIndent, int rightIndent, | ||
Alignment alignment, int lineSpacing) | ||
: Compositor(topIndent, bottomIndent, leftIndent, rightIndent, | ||
alignment, lineSpacing) {} | ||
|
||
~SimpleCompositor() override = default; | ||
|
||
void Compose() override; | ||
|
||
private: | ||
void ComposePage(Page::PagePtr& page, GlyphContainer::GlyphList& list); | ||
void ComposeColumn(Glyph::GlyphPtr& column, int x, int y, int width, | ||
int height, GlyphContainer::GlyphList& list); | ||
void ComposeRow(Glyph::GlyphPtr& row, int x, int y, int width, | ||
GlyphContainer::GlyphList& list); | ||
void ComposeCharacter(Glyph::GlyphPtr& character, int x, int y); | ||
|
||
size_t GetNestedGlyphsCount(Glyph::GlyphPtr& glyph); | ||
int GetNestedGlyphsWidth(Glyph::GlyphPtr& glyph); | ||
int GetNestedGlyphsHeight(Glyph::GlyphPtr& glyph); | ||
|
||
GlyphContainer::GlyphList CutAllCharacters(); | ||
|
||
friend class boost::serialization::access; | ||
template<class Archive> | ||
void serialize(Archive &ar, const unsigned int version) | ||
{ | ||
std::cout << "0 SimpleCompositor\n"; | ||
ar & boost::serialization::base_object<Compositor>(*this); | ||
std::cout << "1 SimpleCompositor\n"; | ||
} | ||
}; | ||
BOOST_CLASS_EXPORT_KEY(SimpleCompositor) | ||
|
||
#endif // TEXT_EDITOR_SIMPLECOMPOSITOR_H_ |
Oops, something went wrong.