Skip to content

Commit

Permalink
Merge branch 'dev' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Oct 24, 2020
2 parents 6d04a05 + b6fe614 commit b2951ad
Show file tree
Hide file tree
Showing 29 changed files with 1,070 additions and 306 deletions.
20 changes: 12 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Windows for compiling everything, but the_Foundation still lacks
# native Win32 implementations for the Socket and Process classes.
# - Windows builds should use the SDL 2 library precompiled for native
# Windows (MSVC variant) instead the version from MSYS2 (get it from
# Windows (MSVC variant) instead of the version from MSYS2 (get it from
# https://libsdl.org/). To make configuration easier, consider writing
# for your personal use a pkg-config sdl2.pc file that uses the Windows
# version of the library.
Expand All @@ -19,18 +19,18 @@
cmake_minimum_required (VERSION 3.9)

project (Lagrange
VERSION 0.5.0
DESCRIPTION "Beautiful Gemini Client"
VERSION 0.6.0
DESCRIPTION "A Beautiful Gemini Client"
LANGUAGES C
)
set (COPYRIGHT_YEAR 2020)

# Build configuration.
option (ENABLE_MPG123 "Use mpg123 for decoding MPEG audio" ON)
option (ENABLE_X11_SWRENDER "Use software rendering under X11" OFF)
option (ENABLE_KERNING "Enable kerning in font renderer (slower)" ON)
option (ENABLE_RESOURCE_EMBED "Embed resources inside the executable" OFF)
option (ENABLE_WINDOWPOS_FIX "Set position after showing window (workaround for SDL bug)" OFF)
option (ENABLE_MPG123 "Use mpg123 for decoding MPEG audio" ON)
option (ENABLE_X11_SWRENDER "Use software rendering under X11" OFF)
option (ENABLE_KERNING "Enable kerning in font renderer (slower)" ON)
option (ENABLE_RESOURCE_EMBED "Embed resources inside the executable" OFF)
option (ENABLE_WINDOWPOS_FIX "Set position after showing window (workaround for SDL bug)" OFF)

include (BuildType.cmake)
include (Embed.cmake)
Expand Down Expand Up @@ -71,6 +71,7 @@ set (EMBED_RESOURCES
res/fonts/Literata-Bold-opsz=36.ttf
res/fonts/Literata-ExtraLight-opsz=18.ttf
res/fonts/Literata-LightItalic-opsz=10.ttf
res/fonts/NanumGothic-Regular.ttf
res/fonts/NotoEmoji-Regular.ttf
res/fonts/Nunito-ExtraBold.ttf
res/fonts/Nunito-ExtraLight.ttf
Expand All @@ -94,6 +95,7 @@ set (SOURCES
src/app.h
src/bookmarks.c
src/bookmarks.h
src/defs.h
src/gmcerts.c
src/gmcerts.h
src/gmdocument.c
Expand Down Expand Up @@ -127,6 +129,8 @@ set (SOURCES
src/ui/command.h
src/ui/documentwidget.c
src/ui/documentwidget.h
src/ui/indicatorwidget.c
src/ui/indicatorwidget.h
src/ui/listwidget.c
src/ui/listwidget.h
src/ui/lookupwidget.c
Expand Down
35 changes: 30 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,44 @@ To install to "/dest/path":

This will also install an XDG .desktop file for launching the app.

### macOS-specific notes
### Compiling on macOS

When using OpenSSL 1.1.1 from Homebrew, you must add its pkgconfig path to your `PKG_CONFIG_PATH` environment variable, for example:

export PKG_CONFIG_PATH=/usr/local/Cellar/[email protected]/1.1.1g/lib/pkgconfig
export PKG_CONFIG_PATH=/usr/local/Cellar/[email protected]/1.1.1h/lib/pkgconfig

Also, SDL's trackpad scrolling behavior on macOS is not optimal for regular GUI apps because it emulates a physical mouse wheel. This may change in a future release of SDL, but at least in 2.0.12 a [small patch](https://git.skyjake.fi/skyjake/lagrange/raw/branch/dev/sdl2-macos-mouse-scrolling-patch.diff) is required to allow momentum scrolling to come through as single-pixel mouse wheel events.
Also, SDL's trackpad scrolling behavior on macOS is not optimal for regular GUI apps because it emulates a physical mouse wheel. This may change in a future release of SDL, but at least in 2.0.12 a [small patch](https://git.skyjake.fi/skyjake/lagrange/raw/branch/dev/sdl2-macos-mouse-scrolling-patch.diff) is required to allow momentum scrolling to come through as single-pixel mouse wheel events. Note that SDL comes with an Xcode project; use the "Shared Library" target and check that you are doing a Release build.

### Raspberry Pi notes
### Compiling on Windows

Windows builds require [MSYS2](https://www.msys2.org). In theory, [Clang](https://clang.llvm.org/docs/MSVCCompatibility.html) or GCC (on [MinGW](http://mingw.org)) could be set up natively on Windows for compiling everything, but the_Foundation still lacks native Win32 implementations for the Socket and Process classes and these are required by Lagrange.

You should use the SDL 2 library precompiled for native Windows (the MSVC variant) instead of the version from MSYS2 or MinGW. You can download a copy of the SDL binaries from https://libsdl.org/. To make configuration easier in your MSYS2 environment, consider writing a custom sdl2.pc file so `pkg-config` can automatically find the correct version of SDL. Below is an example of what your sdl2.pc might look like:

```
prefix=/c/SDK/SDL2-2.0.12/
arch=x64
libdir=${prefix}/lib/${arch}/
incdir=${prefix}/include/
Name: sdl2
Description: Simple DirectMedia Layer
Version: 2.0.12-msvc
Libs: ${libdir}/SDL2.dll -mwindows
Cflags: -I${incdir}
```

The *-mwindows* option is particularly important as that specifies the target is a GUI application. Also note that you are linking directly against the Windows DLL — do not use any prebuilt .lib files if available, as those as specific to MSVC.

`pkg-config` will find your .pc file if it is on `PKG_CONFIG_PATH` or you place it in a system-wide pkgconfig directory.

Once you have compiled a working binary under MSYS2, there is still an additional step required to allow running it directly from the Windows shell: the shared libraries from MSYS2 must be found either via `PATH` or by copying them to the same directory where `lagrange.exe` is located.

### Compiling on Raspberry Pi

You should use a version of SDL that is compiled to take advantage of the Broadcom VideoCore OpenGL ES hardware. This provides the best performance when running Lagrange in a console.

When running under X11, software rendering is the best choice and in that case the SDL from Raspbian etc. is sufficient.
At present time, OpenGL under X11 on Raspberry Pi is still quite slow/experimental. When running under X11, software rendering is the best choice and the SDL from Raspbian etc. is sufficient.

The following build options are recommended on Raspberry Pi:

Expand Down
1 change: 1 addition & 0 deletions res/about/license.gmi
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ This application uses fonts licensed under the Open Font License.
=> https://fonts.google.com/specimen/EB+Garamond#license EB Garamond
=> https://github.com/mozilla/Fira/blob/master/LICENSE Fira Sans, Fira Mono
=> https://github.com/googlefonts/literata/blob/master/OFL.txt Literata
=> https://github.com/google/fonts/blob/master/ofl/nanumgothic/OFL.txt Nanum Gothic
=> https://github.com/googlefonts/nunito/blob/master/OFL.txt Nunito
=> https://github.com/adobe-fonts/source-sans-pro/blob/release/LICENSE.md Source Sans Pro

Expand Down
11 changes: 11 additions & 0 deletions res/about/version.gmi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
```
# Release notes

## 0.6
* Added an indicator to visualize progress of network requests.
* Added new color themes for page content: Colorful Light, Black, Gray, Sepia, High Contrast.
* Added page content color theme selection in Preferences.
* Added quote indicator option: icon or vertical line.
* Added a new font for Korean glyhps.
* Smoother smooth scrolling, making it easier to keep one's eyes on the content throughout the motion.
* Windows: Register Lagrange as a handler of "gemini:" URLs.
* macOS: Fixed glitchy window dragging during audio playback.
* Fixed timestamps of cached pages.

## 0.5
* Added MP3 support in the audio player (using mpg123).
=> https://mpg123.org/ mpg123: MPEG audio player and decoder library
Expand Down
96 changes: 96 additions & 0 deletions res/fonts/LICENSE_NanumGothic.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
Copyright (c) 2010, NHN Corporation (http://www.nhncorp.com),
with Reserved Font Name Nanum, Naver Nanum, NanumGothic, Naver
NanumGothic, NanumMyeongjo, Naver NanumMyeongjo, NanumBrush, Naver
NanumBrush, NanumPen, Naver NanumPen.

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file added res/fonts/NanumGothic-Regular.ttf
Binary file not shown.
2 changes: 1 addition & 1 deletion res/lagrange.rc.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "Jaakko Ker\xe4nen\0"
VALUE "FileDescription", "${PROJECT_DESCRIPTION}\0"
VALUE "FileDescription", "Lagrange: ${PROJECT_DESCRIPTION}\0"
VALUE "FileVersion", "${PROJECT_VERSION}\0"
VALUE "InternalName", "fi.skyjake.lagrange\0"
VALUE "LegalCopyright", "(c) ${COPYRIGHT_YEAR} Jaakko Ker\xe4nen\0"
Expand Down
57 changes: 54 additions & 3 deletions src/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

#include "app.h"
#include "bookmarks.h"
#include "defs.h"
#include "embedded.h"
#include "gmcerts.h"
#include "gmdocument.h"
Expand Down Expand Up @@ -181,9 +182,12 @@ static iString *serializePrefs_App_(const iApp *d) {
appendFormat_String(str, "linewidth.set arg:%d\n", d->prefs.lineWidth);
appendFormat_String(str, "prefs.biglede.changed arg:%d\n", d->prefs.bigFirstParagraph);
appendFormat_String(str, "prefs.sideicon.changed arg:%d\n", d->prefs.sideIcon);
appendFormat_String(str, "quoteicon.set arg:%d\n", d->prefs.quoteIcon ? 1 : 0);
appendFormat_String(str, "prefs.hoveroutline.changed arg:%d\n", d->prefs.hoverOutline);
appendFormat_String(str, "theme.set arg:%d auto:1\n", d->prefs.theme);
appendFormat_String(str, "ostheme arg:%d\n", d->prefs.useSystemTheme);
appendFormat_String(str, "doctheme.dark.set arg:%d\n", d->prefs.docThemeDark);
appendFormat_String(str, "doctheme.light.set arg:%d\n", d->prefs.docThemeLight);
appendFormat_String(str, "saturation.set arg:%d\n", (int) ((d->prefs.saturation * 100) + 0.5f));
appendFormat_String(str, "proxy.gopher address:%s\n", cstr_String(&d->prefs.gopherProxy));
appendFormat_String(str, "proxy.http address:%s\n", cstr_String(&d->prefs.httpProxy));
Expand Down Expand Up @@ -253,9 +257,9 @@ static iBool loadState_App_(iApp *d) {
printf("%s: format not recognized\n", cstr_String(path_File(f)));
return iFalse;
}
const int version = read32_File(f);
const uint32_t version = readU32_File(f);
/* Check supported versions. */
if (version != 0) {
if (version > latest_FileVersion) {
printf("%s: unsupported version\n", cstr_String(path_File(f)));
return iFalse;
}
Expand Down Expand Up @@ -301,7 +305,7 @@ static void saveState_App_(const iApp *d) {
iFile *f = newCStr_File(concatPath_CStr(dataDir_App_, stateFileName_App_));
if (open_File(f, writeOnly_FileMode)) {
writeData_File(f, magicState_App_, 4);
write32_File(f, 0); /* version */
writeU32_File(f, latest_FileVersion); /* version */
iConstForEach(ObjectList, i, iClob(listDocuments_App())) {
if (isInstance_Object(i.object, &Class_DocumentWidget)) {
writeData_File(f, magicTabDocument_App_, 4);
Expand Down Expand Up @@ -700,6 +704,18 @@ static void updatePrefsThemeButtons_(iWidget *d) {
}
}

static void updateColorThemeButton_(iLabelWidget *button, int theme) {
const char *mode = strstr(cstr_String(id_Widget(as_Widget(button))), ".dark") ? "dark" : "light";
const char *command = format_CStr("doctheme.%s.set arg:%d", mode, theme);
iForEach(ObjectList, i, children_Widget(findChild_Widget(as_Widget(button), "menu"))) {
iLabelWidget *item = i.object;
if (!cmp_String(command_LabelWidget(item), command)) {
updateText_LabelWidget(button, label_LabelWidget(item));
break;
}
}
}

static iBool handlePrefsCommands_(iWidget *d, const char *cmd) {
if (equal_Command(cmd, "prefs.dismiss") || equal_Command(cmd, "preferences")) {
setUiScale_Window(get_Window(),
Expand All @@ -720,6 +736,20 @@ static iBool handlePrefsCommands_(iWidget *d, const char *cmd) {
destroy_Widget(d);
return iTrue;
}
else if (equal_Command(cmd, "quoteicon.set")) {
const int arg = arg_Command(cmd);
setFlags_Widget(findChild_Widget(d, "prefs.quoteicon.0"), selected_WidgetFlag, arg == 0);
setFlags_Widget(findChild_Widget(d, "prefs.quoteicon.1"), selected_WidgetFlag, arg == 1);
return iFalse;
}
else if (equal_Command(cmd, "doctheme.dark.set")) {
updateColorThemeButton_(findChild_Widget(d, "prefs.doctheme.dark"), arg_Command(cmd));
return iFalse;
}
else if (equal_Command(cmd, "doctheme.light.set")) {
updateColorThemeButton_(findChild_Widget(d, "prefs.doctheme.light"), arg_Command(cmd));
return iFalse;
}
else if (equal_Command(cmd, "prefs.ostheme.changed")) {
postCommandf_App("ostheme arg:%d", arg_Command(cmd));
}
Expand Down Expand Up @@ -908,11 +938,26 @@ iBool handleCommand_App(const char *cmd) {
d->prefs.useSystemTheme = arg_Command(cmd);
return iTrue;
}
else if (equal_Command(cmd, "doctheme.dark.set")) {
d->prefs.docThemeDark = arg_Command(cmd);
postCommand_App("theme.changed auto:1");
return iTrue;
}
else if (equal_Command(cmd, "doctheme.light.set")) {
d->prefs.docThemeLight = arg_Command(cmd);
postCommand_App("theme.changed auto:1");
return iTrue;
}
else if (equal_Command(cmd, "linewidth.set")) {
d->prefs.lineWidth = iMax(20, arg_Command(cmd));
postCommand_App("document.layout.changed");
return iTrue;
}
else if (equal_Command(cmd, "quoteicon.set")) {
d->prefs.quoteIcon = arg_Command(cmd) != 0;
postCommand_App("document.layout.changed");
return iTrue;
}
else if (equal_Command(cmd, "prefs.biglede.changed")) {
d->prefs.bigFirstParagraph = arg_Command(cmd) != 0;
postCommand_App("document.layout.changed");
Expand Down Expand Up @@ -1058,8 +1103,14 @@ iBool handleCommand_App(const char *cmd) {
findChild_Widget(dlg, format_CStr("prefs.linewidth.%d", d->prefs.lineWidth)),
selected_WidgetFlag,
iTrue);
setFlags_Widget(
findChild_Widget(dlg, format_CStr("prefs.quoteicon.%d", d->prefs.quoteIcon)),
selected_WidgetFlag,
iTrue);
setToggle_Widget(findChild_Widget(dlg, "prefs.biglede"), d->prefs.bigFirstParagraph);
setToggle_Widget(findChild_Widget(dlg, "prefs.sideicon"), d->prefs.sideIcon);
updateColorThemeButton_(findChild_Widget(dlg, "prefs.doctheme.dark"), d->prefs.docThemeDark);
updateColorThemeButton_(findChild_Widget(dlg, "prefs.doctheme.light"), d->prefs.docThemeLight);
setFlags_Widget(
findChild_Widget(
dlg, format_CStr("prefs.saturation.%d", (int) (d->prefs.saturation * 3.99f))),
Expand Down
Loading

0 comments on commit b2951ad

Please sign in to comment.