Skip to content

Commit

Permalink
Human readable encoding (#129)
Browse files Browse the repository at this point in the history
This makes Forscape use a human-readable encoding. The special symbols are the same as YAWYSIWYGEE, but the construct mapping using ASCII keywords. The special characters are:

⁜ - Construct symbol
⏴- Open argument symbol
⏵- Close argument symbol

This also includes a few crash fixes, and introduces a regression test for the export-to-unicode capability.
  • Loading branch information
JohnDTill authored Nov 2, 2024
1 parent 6f0de70 commit 5da147d
Show file tree
Hide file tree
Showing 170 changed files with 2,080 additions and 1,779 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/app_compiles_and_runs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- id: Qt
uses: jurplel/install-qt-action@v3
uses: jurplel/install-qt-action@v4
- uses: actions/checkout@v3
- id: install_conan
uses: turtlebrowser/get-conan@main
with:
version: 1.59.0
version: 1.65.0
- id: patch_conan
run: conan profile new default --detect && conan profile update settings.compiler.libcxx=libstdc++11 default
- id: run_conan
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cpp_integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- id: install_conan
uses: turtlebrowser/get-conan@main
with:
version: 1.59.0
version: 1.65.0
- id: patch_conan
run: conan profile new default --detect && conan profile update settings.compiler.libcxx=libstdc++11 default
- id: run_conan
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cpp_integration_tests_32bit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- id: install_conan
uses: turtlebrowser/get-conan@main
with:
version: 1.59.0
version: 1.65.0
- id: patch_conan
run: conan profile new default --detect && conan profile update settings.compiler.libcxx=libstdc++11 default
- id: run_conan
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cpp_integration_tests_clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- id: install_conan
uses: turtlebrowser/get-conan@main
with:
version: 1.59.0
version: 1.65.0
- id: run_conan
run: cd ${GITHUB_WORKSPACE}/test && export CXX=/usr/bin/clang++ &&
conan install -e CXX=/usr/bin/clang++ --generator cmake_find_package --install-folder ../build_test/conan-dependencies .
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/cpp_integration_tests_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- id: install_conan
uses: turtlebrowser/get-conan@main
with:
version: 1.59.0
version: 1.65.0
- id: run_conan
run: cd ${GITHUB_WORKSPACE}/test && conan install --generator cmake_find_package --install-folder ../build_test/conan-dependencies .
- id: cmake
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cpp_integration_tests_win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- id: install_conan
uses: turtlebrowser/get-conan@main
with:
version: 1.59.0
version: 1.65.0
- id: run_conan
run: cd $Env:GITHUB_WORKSPACE/test && conan install --generator cmake_find_package --install-folder ../build_test/conan-dependencies .
- id: cmake
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/qt_integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- id: Qt
uses: jurplel/install-qt-action@v3
uses: jurplel/install-qt-action@v4
- uses: actions/checkout@v3
- id: install_conan
uses: turtlebrowser/get-conan@main
with:
version: 1.59.0
version: 1.65.0
- id: patch_conan
run: conan profile new default --detect && conan profile update settings.compiler.libcxx=libstdc++11 default
- id: run_conan
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/qt_integration_tests_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@ jobs:
runs-on: macos-latest
steps:
- id: Qt
uses: jurplel/install-qt-action@v3
uses: jurplel/install-qt-action@v4
- uses: actions/checkout@v3
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- id: install_conan
uses: turtlebrowser/get-conan@main
with:
version: 1.59.0
version: 1.65.0
- id: run_conan
run: cd ${GITHUB_WORKSPACE}/test && conan install --generator cmake_find_package --install-folder ../build_test/conan-dependencies .
- id: cmake
run: cd ${GITHUB_WORKSPACE}/test && cmake -DCMAKE_BUILD_TYPE=Debug -DTEST_QT=ON -B../build_test -S.
run: cd ${GITHUB_WORKSPACE}/test && cmake -DCMAKE_BUILD_TYPE=Debug -DTEST_QT=ON -DCMAKE_OSX_ARCHITECTURES=x86_64 -B../build_test -S.
- id: make
run: cd ${GITHUB_WORKSPACE}/build_test && make
- id: run
Expand Down
2 changes: 2 additions & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ set(GEN_FILES
${GEN}/code_ast_fields.h
${GEN}/code_error_types.h
${GEN}/code_parsenode_ops.h
${GEN}/code_settings_constants.cpp
${GEN}/code_settings_constants.h
${GEN}/code_tokentype.h
${GEN}/construct_codes.h
${GEN}/forscape_interpreter_gen.cpp
Expand Down
2 changes: 1 addition & 1 deletion app/conanfile.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[requires]
eigen/3.4.0
# gmp/6.3.0
parallel-hashmap/1.37
parallel-hashmap/1.4.1
readerwriterqueue/1.0.6

[generators]
Expand Down
20 changes: 7 additions & 13 deletions app/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,10 +735,7 @@ void MainWindow::openProject(QString path){
buffer << in.rdbuf();

std::string src = buffer.str();
for(size_t i = 1; i < src.size(); i++)
if(src[i] == '\r' && src[i-1] != OPEN)
src[i] = '\0';
src.erase( std::remove(src.begin(), src.end(), '\0'), src.end() );
src.erase( std::remove(src.begin(), src.end(), '\r'), src.end() );

if(isIllFormedUtf8(src)){
QMessageBox messageBox;
Expand Down Expand Up @@ -951,7 +948,7 @@ void MainWindow::insertSerialSelection(const QString& A, const QString& B){
}

void MainWindow::insertSettings() {
insertSerial(OPEN_STR SETTINGS_STR "");
insertSerial(CONSTRUCT_STR SETTINGS_STR OPEN_STR CLOSE_STR);
Typeset::Construct* settings = editor->getController().getActive().text->prevConstructAsserted();
Typeset::Settings::changeSettings(settings, editor->getController());
Typeset::Settings::expandCollapse(settings, editor->getController());
Expand Down Expand Up @@ -994,10 +991,10 @@ void MainWindow::on_actionTeX_triggered(){
}

void MainWindow::on_actionUnicode_triggered(){
std::string str = editor->getController().selectedText();
if(UnicodeConverter::canConvert(str)){
std::string uni = UnicodeConverter::convert(str);
QApplication::clipboard()->setText(toQString(uni));
std::string str;
const bool success = editor->getController().selection().convertToUnicode(str);
if(success){
QApplication::clipboard()->setText(toQString(str));
}else{
QMessageBox messageBox;
messageBox.warning(nullptr, "Warning", "Selected text cannot be converted to unicode.");
Expand Down Expand Up @@ -1293,10 +1290,7 @@ void MainWindow::on_actionReload_triggered() {
buffer << in.rdbuf();

std::string src = buffer.str();
for(size_t i = 1; i < src.size(); i++)
if(src[i] == '\r' && src[i-1] != OPEN)
src[i] = '\0';
src.erase( std::remove(src.begin(), src.end(), '\0'), src.end() );
src.erase( std::remove(src.begin(), src.end(), '\r'), src.end() );

if(isIllFormedUtf8(src)){
QMessageBox messageBox;
Expand Down
Loading

0 comments on commit 5da147d

Please sign in to comment.