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

All of my changes rebased on dev #919

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d0be464
Info.plist: Add CFBundleName
satoqz Jul 28, 2023
4822b65
Update maintainer for AUR sioyek-git
hrdl-github Oct 6, 2023
929345f
Don't allow nan values in toc nodes.
hrdl-github Oct 12, 2023
4322ff2
Add path into build_mac.sh
jinjiaodawang Nov 3, 2023
0848754
Change Unix commands to Windows commands
smooroodina Nov 19, 2023
51a641b
README.md: Updated macOS build instructions
NightMachinery Jan 6, 2024
5fd403e
treating backspace as delete
NightMachinery Jan 12, 2024
212b02a
added shouldTriggerDelete
NightMachinery Jan 12, 2024
5f8f684
renamed shouldTriggerDelete to should_trigger_delete
NightMachinery Jan 12, 2024
7959743
updated build instructions for macOS, added missing import to pdf_vie…
NightMachinery Jan 12, 2024
b1d1d47
move_horizontal: added ignore_lock_p; shift+scrolling works even with…
NightMachinery Jan 13, 2024
5cfd62a
build_mac.sh: added SIOYEK_BUILD_INCREMENTAL_P (empty after rebase)
NightMachinery Jan 13, 2024
940611e
MainWidget: added isKeyPressed
NightMachinery Jan 13, 2024
cb80499
MainWidget::wheelEvent: escape+scroll also scrolls horizontally
NightMachinery Jan 13, 2024
0bfc5a6
NIGHT_P: added hiredis, redisFlagGet
NightMachinery Jan 13, 2024
8be7dd2
NIGHT_P: config changes in scroll_horizontally_p and zoom_p
NightMachinery Jan 13, 2024
9b05564
added delete_last_highlight
NightMachinery Jan 14, 2024
1da0d69
keys.config: added delete_last_highlight
NightMachinery Jan 14, 2024
434f172
added scroll_zoom_inc_factor
NightMachinery Jan 14, 2024
a6b75d7
added regex_searching
NightMachinery Jan 14, 2024
2eeabd7
InputHandler::handle_key: fixed bug in handling Backspace on macOS
NightMachinery Jan 15, 2024
0ae615d
added previous_page_smart, next_page_smart
NightMachinery Jan 15, 2024
53e99fe
added PushStateCommand
NightMachinery Jan 15, 2024
ef13e13
added keyboard_select_copy_p
NightMachinery Jan 16, 2024
28ded77
fixed typo in the doc of previous_page_smart
NightMachinery Jan 16, 2024
6a48415
BaseSelectorWidget: uses should_trigger_delete on QT 6
NightMachinery Jan 18, 2024
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -372,3 +372,5 @@ tutorial/*.bbl
tutorial/*.blg
*.o.d
compile_commands.json

qrc_resources.cpp
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Distro | Link | Maintainer
Flathub | [sioyek](https://flathub.org/apps/details/com.github.ahrm.sioyek) | [@nbenitez](https://flathub.org/apps/details/com.github.ahrm.sioyek)
Alpine | [sioyek](https://pkgs.alpinelinux.org/packages?name=sioyek) | [@jirutka](https://github.com/jirutka)
Arch | [AUR sioyek](https://aur.archlinux.org/packages/sioyek) | [@goggle](https://github.com/goggle)
Arch | [AUR Sioyek-git](https://aur.archlinux.org/packages/sioyek-git/) | [@randomn4me](https://github.com/randomn4me)
Arch | [AUR sioyek-git](https://aur.archlinux.org/packages/sioyek-git/) | [@hrdl-github](https://github.com/hrdl-github)
Arch | [AUR sioyek-appimage](https://aur.archlinux.org/packages/sioyek-appimage/) | [@DhruvaSambrani](https://github.com/DhruvaSambrani)
Debian | [sioyek](https://packages.debian.org/sioyek) | [@viccie30](https://github.com/viccie30)
NixOS | [sioyek](https://search.nixos.org/packages?channel=unstable&show=sioyek&from=0&size=50&sort=relevance&type=packages&query=sioyek) | [@podocarp](https://github.com/podocarp)
Expand Down Expand Up @@ -151,13 +151,27 @@ build_windows.bat
```

### Mac
1. Install Xcode and Qt 5.
2. Clone the repository and build:
```
1. Install Xcode.
2. Clone the repository and build: (The code below is in Zsh, which is the default shell on macOS.)
```zsh
(
setopt PIPE_FAIL PRINT_EXIT_VALUE ERR_RETURN SOURCE_TRACE XTRACE

git clone --recursive https://github.com/ahrm/sioyek
cd sioyek
chmod +x build_mac.sh
./build_mac.sh

brew install 'qt@5' freeglut mesa harfbuzz

export PATH="/opt/homebrew/opt/qt@5/bin:$PATH"
#: The above is needed to make =qmake= from =qt= be found.
#: Find the path using =brew info 'qt@5'=.

MAKE_PARALLEL=8 ./build_mac.sh

mv build/sioyek.app /Applications/
sudo codesign --force --sign - --deep /Applications/sioyek.app
)
```

## Donation
Expand Down
39 changes: 31 additions & 8 deletions build_mac.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#!/usr/bin/env bash
set -e
# prerequisite: brew install qt@5 freeglut mesa harfbuzz
set -exo pipefail

# prerequisite: brew install qt qt@5 freeglut mesa harfbuzz hiredis
export INCLUDE_PATH=/opt/homebrew/include
export LIBRARY_PATH=/opt/homebrew/lib

incremental_p="${SIOYEK_BUILD_INCREMENTAL_P}"
# Using `SIOYEK_BUILD_INCREMENTAL_P=y` will cause the build script to become optimized for the local development builds and not publishing the app.

#sys_glut_clfags=`pkg-config --cflags glut gl`
#sys_glut_libs=`pkg-config --libs glut gl`
Expand All @@ -12,15 +18,20 @@ echo "MAKE_PARALLEL set to $MAKE_PARALLEL"

cd mupdf
#make USE_SYSTEM_HARFBUZZ=yes USE_SYSTEM_GLUT=yes SYS_GLUT_CFLAGS="${sys_glut_clfags}" SYS_GLUT_LIBS="${sys_glut_libs}" SYS_HARFBUZZ_CFLAGS="${sys_harfbuzz_clfags}" SYS_HARFBUZZ_LIBS="${sys_harfbuzz_libs}" -j 4
make
make XLIBS="-L${LIBRARY_PATH}"
cd ..

qmake_opts=()
if test -n "${SIOYEK_NIGHT_P}" ; then
qmake_opts+=("DEFINES+=NIGHT_P")
fi

if [[ $1 == portable ]]; then
qmake pdf_viewer_build_config.pro
else
qmake "CONFIG+=non_portable" pdf_viewer_build_config.pro
qmake_opts+=("CONFIG+=non_portable")
fi

qmake "${qmake_opts[@]}" pdf_viewer_build_config.pro

make -j$MAKE_PARALLEL

rm -rf build 2> /dev/null
Expand All @@ -34,5 +45,17 @@ cp pdf_viewer/keys.config build/sioyek.app/Contents/MacOS/keys.config
cp pdf_viewer/keys_user.config build/sioyek.app/Contents/MacOS/keys_user.config
cp tutorial.pdf build/sioyek.app/Contents/MacOS/tutorial.pdf

macdeployqt build/sioyek.app -dmg
zip -r sioyek-release-mac.zip build/sioyek.dmg
if test -z "${incremental_p}" ; then
# Capture the current PATH
CURRENT_PATH=$(echo $PATH)

# Define the path to the Info.plist file inside the app bundle
INFO_PLIST="resources/Info.plist"

# Add LSEnvironment key with PATH to Info.plist
/usr/libexec/PlistBuddy -c "Add :LSEnvironment dict" "$INFO_PLIST" || echo "LSEnvironment already exists"
/usr/libexec/PlistBuddy -c "Add :LSEnvironment:PATH string $CURRENT_PATH" "$INFO_PLIST" || /usr/libexec/PlistBuddy -c "Set :LSEnvironment:PATH $CURRENT_PATH" "$INFO_PLIST"

macdeployqt build/sioyek.app -dmg
zip -r sioyek-release-mac.zip build/sioyek.dmg
fi
22 changes: 11 additions & 11 deletions build_windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ if %1 == portable (
)

msbuild -maxcpucount sioyek.vcxproj /property:Configuration=Release
rm -r sioyek-release-windows 2> NUL
rmdir /S sioyek-release-windows
mkdir sioyek-release-windows
cp release\sioyek.exe sioyek-release-windows\sioyek.exe
cp pdf_viewer\keys.config sioyek-release-windows\keys.config
cp pdf_viewer\prefs.config sioyek-release-windows\prefs.config
cp -r pdf_viewer\shaders sioyek-release-windows\shaders
cp tutorial.pdf sioyek-release-windows\tutorial.pdf
copy release\sioyek.exe sioyek-release-windows\sioyek.exe
copy pdf_viewer\keys.config sioyek-release-windows\keys.config
copy pdf_viewer\prefs.config sioyek-release-windows\prefs.config
xcopy /E /I pdf_viewer\shaders sioyek-release-windows\shaders\
copy tutorial.pdf sioyek-release-windows\tutorial.pdf
windeployqt sioyek-release-windows\sioyek.exe
cp windows_runtime\vcruntime140_1.dll sioyek-release-windows\vcruntime140_1.dll
cp windows_runtime\libssl-1_1-x64.dll sioyek-release-windows\libssl-1_1-x64.dll
cp windows_runtime\libcrypto-1_1-x64.dll sioyek-release-windows\libcrypto-1_1-x64.dll
copy windows_runtime\vcruntime140_1.dll sioyek-release-windows\vcruntime140_1.dll
copy windows_runtime\libssl-1_1-x64.dll sioyek-release-windows\libssl-1_1-x64.dll
copy windows_runtime\libcrypto-1_1-x64.dll sioyek-release-windows\libcrypto-1_1-x64.dll

if %1 == portable (
cp pdf_viewer\keys_user.config sioyek-release-windows\keys_user.config
cp pdf_viewer\prefs_user.config sioyek-release-windows\prefs_user.config
copy pdf_viewer\keys_user.config sioyek-release-windows\keys_user.config
copy pdf_viewer\prefs_user.config sioyek-release-windows\prefs_user.config
7z a sioyek-release-windows-portable.zip sioyek-release-windows

) else (
Expand Down
28 changes: 28 additions & 0 deletions pdf_viewer/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//#include <ui.h>

extern float ZOOM_INC_FACTOR;
extern float SCROLL_ZOOM_INC_FACTOR;
extern float GAMMA;
extern float VERTICAL_MOVE_AMOUNT;
extern float HORIZONTAL_MOVE_AMOUNT;
Expand All @@ -15,6 +16,7 @@ extern float UNSELECTED_SEARCH_HIGHLIGHT_COLOR[3];
extern float DARK_MODE_BACKGROUND_COLOR[3];
extern float CUSTOM_COLOR_MODE_EMPTY_BACKGROUND_COLOR[3];
extern float DARK_MODE_CONTRAST;
extern bool KEYBOARD_SELECT_COPY_P;
extern bool FLAT_TABLE_OF_CONTENTS;
extern bool SMALL_TOC;
extern bool SHOULD_USE_MULTIPLE_MONITORS;
Expand Down Expand Up @@ -167,6 +169,7 @@ extern bool SHOULD_HIGHLIGHT_LINKS;
extern bool SHOULD_HIGHLIGHT_UNSELECTED_SEARCH;
extern int KEYBOARD_SELECT_FONT_SIZE;
extern bool FUZZY_SEARCHING;
extern bool REGEX_SEARCHING;
extern float CUSTOM_COLOR_CONTRAST;
extern bool DEBUG;
extern bool DEBUG_DISPLAY_FREEHAND_POINTS;
Expand Down Expand Up @@ -718,6 +721,15 @@ ConfigManager::ConfigManager(const Path& default_path, const Path& auto_path, co
nullptr,
FloatExtras{1.0f, 2.0f}
});
configs.push_back({
L"scroll_zoom_inc_factor",
ConfigType::Float,
&SCROLL_ZOOM_INC_FACTOR,
float_serializer,
float_deserializer,
nullptr,
FloatExtras{1.0f, 6.0f}
});
configs.push_back({
L"vertical_move_amount",
ConfigType::Float,
Expand Down Expand Up @@ -1861,6 +1873,22 @@ ConfigManager::ConfigManager(const Path& default_path, const Path& auto_path, co
bool_deserializer,
bool_validator
});
configs.push_back({
L"regex_searching",
ConfigType::Bool,
&REGEX_SEARCHING,
bool_serializer,
bool_deserializer,
bool_validator
});
configs.push_back({
L"keyboard_select_copy_p",
ConfigType::Bool,
&KEYBOARD_SELECT_COPY_P,
bool_serializer,
bool_deserializer,
bool_validator
});
configs.push_back({
L"debug",
ConfigType::Bool,
Expand Down
2 changes: 2 additions & 0 deletions pdf_viewer/coordinates.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <algorithm>

#include <qpoint.h>
#include <mupdf/fitz.h>
#include <qopengl.h>
Expand Down
37 changes: 23 additions & 14 deletions pdf_viewer/document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,15 @@ void Document::delete_highlight_with_index(int index) {
is_annotations_dirty = true;
}

void Document::delete_last_highlight() {
if (!highlights.empty()) {

int last_index = highlights.size() - 1;

delete_highlight_with_index(last_index);
}
}

void Document::delete_highlight(Highlight hl) {
for (size_t i = (highlights.size() - 1); i >= 0; i--) {
if (highlights[i] == hl) {
Expand Down Expand Up @@ -803,20 +812,20 @@ void Document::convert_toc_tree(fz_outline* root, std::vector<TocNode*>& output)
break;
}

TocNode* current_node = new TocNode;
current_node->title = utf8_decode(root->title);
current_node->x = root->x;
current_node->y = root->y;
if (root->page.page == -1) {
float xp, yp;
fz_location loc = fz_resolve_link(context, doc, root->uri, &xp, &yp);
int chapter_page = accum_chapter_pages[loc.chapter];
current_node->page = chapter_page + loc.page;
}
else {
current_node->page = root->page.page;
}
convert_toc_tree(root->down, current_node->children);
TocNode* current_node = new TocNode;
current_node->title = utf8_decode(root->title);
current_node->x = std::isnan(root->x) ? 0.0 : root->x;
current_node->y = std::isnan(root->y) ? 0.0 : root->y;
if (root->page.page == -1) {
float xp, yp;
fz_location loc = fz_resolve_link(context, doc, root->uri, &xp, &yp);
int chapter_page = accum_chapter_pages[loc.chapter];
current_node->page = chapter_page + loc.page;
}
else {
current_node->page = root->page.page;
}
convert_toc_tree(root->down, current_node->children);


output.push_back(current_node);
Expand Down
1 change: 1 addition & 0 deletions pdf_viewer/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class Document {
std::string add_highlight(const std::wstring& desc, const std::vector<AbsoluteRect>& highlight_rects, AbsoluteDocumentPos selection_begin, AbsoluteDocumentPos selection_end, char type);
std::string add_highlight(const std::wstring& annot, AbsoluteDocumentPos selection_begin, AbsoluteDocumentPos selection_end, char type);
void delete_highlight_with_index(int index);
void delete_last_highlight();
void delete_highlight(Highlight hl);
int get_bookmark_index_at_pos(AbsoluteDocumentPos abspos);
int get_portal_index_at_pos(AbsoluteDocumentPos abspos);
Expand Down
Loading
Loading