Skip to content

Commit

Permalink
replace ICU with utf8.h
Browse files Browse the repository at this point in the history
  • Loading branch information
GaZaTu committed Jul 13, 2023
1 parent 991faa5 commit 6df823d
Show file tree
Hide file tree
Showing 5 changed files with 1,713 additions and 25 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ jobs:
options: --privileged
strategy:
matrix:
image: ['ubuntu:23.04', 'ubuntu:22.10', 'ubuntu:22.04', 'ubuntu:20.04', 'ubuntu:18.04', 'debian:11', 'debian:10', 'debian:9', 'opensuse/leap:15.4', 'opensuse/leap:15.3', 'opensuse/leap:15.2', 'opensuse/leap:15.1', 'fedora:38', 'fedora:37', 'fedora:36', 'fedora:35']
image: ['ubuntu:23.04', 'ubuntu:22.10', 'ubuntu:22.04', 'ubuntu:20.04', 'debian:12', 'debian:11', 'debian:10', 'debian:9', 'opensuse/leap:15.5', 'opensuse/leap:15.4', 'fedora:39', 'fedora:38', 'fedora:37']
fail-fast: false

steps:
- name: Install dependencies (ubuntu & debian)
if: startsWith(matrix.image, 'ubuntu') || startsWith(matrix.image, 'debian')
run: apt update && apt install -y wget file dpkg-dev fuse git g++ cmake qtbase5-dev libicu-dev libxdo-dev
run: apt update && apt install -y wget file dpkg-dev fuse git g++ cmake qtbase5-dev libxdo-dev

- name: Install dependencies (debian:9)
if: startsWith(matrix.image, 'debian:9')
run: apt install qt5-default

- name: Install dependencies (opensuse)
if: startsWith(matrix.image, 'opensuse')
run: zypper refresh && zypper install -y tar gzip wget rpm-build git gcc-c++ cmake libqt5-qtbase-devel libicu-devel xdotool-devel
run: zypper refresh && zypper install -y tar gzip rpm-build git gcc-c++ cmake libqt5-qtbase-devel xdotool-devel

- name: Install dependencies (fedora)
if: startsWith(matrix.image, 'fedora')
run: dnf clean expire-cache && dnf install -y tar gzip wget rpm-build git gcc-c++ cmake qt5-qtbase-devel libicu-devel libxdo-devel
run: dnf clean expire-cache && dnf install -y tar gzip rpm-build git gcc-c++ cmake qt5-qtbase-devel libxdo-devel

- name: Install dependencies .AppImage
if: startsWith(matrix.image, 'debian:9')
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
make package
- name: Package .AppImage
if: "startsWith(matrix.image, 'debian:9')"
if: startsWith(matrix.image, 'debian:9')
run: |
cd build
make appimage
Expand All @@ -115,7 +115,7 @@ jobs:
mv build/x11-emoji-picker-x86_64.rpm build/${{env.ARTIFACT_NAME_WITH_DISTRO}}.rpm
- name: Rename artifact .AppImage
if: "startsWith(matrix.image, 'debian:9')"
if: startsWith(matrix.image, 'debian:9')
run: |
mv build/x11-emoji-picker-dev-x86_64.AppImage build/${{env.ARTIFACT_NAME}}.AppImage
Expand Down
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.7.2 FATAL_ERROR)
project(emoji-picker VERSION 0.14.0 LANGUAGES CXX)
project(emoji-picker VERSION 0.15.0 LANGUAGES CXX)

set(PROJECT_NAME_FULL x11-emoji-picker)
set(PROJECT_ORGANIZATION gazatu.xyz)
Expand All @@ -21,8 +21,6 @@ set(CMAKE_AUTORCC ON)

find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets)

find_package(ICU REQUIRED COMPONENTS uc)

if (UNIX AND NOT APPLE) # LINUX (X11)
find_library(XDOTOOL_LIB xdo REQUIRED)
add_library(XDOTOOL STATIC SHARED IMPORTED)
Expand Down Expand Up @@ -77,7 +75,6 @@ target_link_libraries(${PROJECT_NAME}
Qt5::Core
Qt5::Gui
Qt5::Widgets
ICU::uc
)

if (UNIX AND NOT APPLE) # LINUX (X11)
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,16 @@ This is a CMake project so you need `cmake`, `make` and some c++ compiler like `
### Dependencies

- Qt5 (core, gui, widgets)
- ICU (uc)
- xdotool

**Arch**:
`sudo pacman -S qt5-base icu xdotool`
`sudo pacman -S qt5-base xdotool`

**Debian**:
`sudo apt install qtbase5-dev libicu-dev libxdo-dev`
`sudo apt install qtbase5-dev libxdo-dev`

**openSUSE**:
`sudo zypper install libqt5-qtbase-devel libicu-devel xdotool-devel`
`sudo zypper install libqt5-qtbase-devel xdotool-devel`

### CMake

Expand Down
24 changes: 13 additions & 11 deletions src/EmojiLabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
#include <QScreen>
#include <QWindow>
#include <sstream>
#include <unicode/schriter.h>
#include <unicode/unistr.h>
#include "utf8.h"

EmojiLabel::EmojiLabel(QWidget* parent, const EmojiPickerSettings& settings) : QLabel(parent), _settings(settings) {
setProperty("class", "EmojiLabel");
Expand All @@ -27,15 +26,18 @@ EmojiLabel::EmojiLabel(QWidget* parent, const EmojiPickerSettings& settings, con
}

void getCodepointsByEmojiStr(const std::string& emojiStr, const std::string& separator, std::stringstream& emojiHexCodeStream) {
bool firstCodepoint = true;
icu::UnicodeString emojiUStr(emojiStr.data(), emojiStr.length(), "utf-8");
icu::StringCharacterIterator emojiUStrIterator(emojiUStr);
while (emojiUStrIterator.hasNext()) {
int32_t codepoint = emojiUStrIterator.next32PostInc();

if (firstCodepoint) {
firstCodepoint = false;
} else {
const utf8_int8_t* ptr = emojiStr.data();
utf8_int32_t codepoint = 0;

while (true) {
bool first = codepoint == 0;

ptr = utf8codepoint(ptr, &codepoint);
if (codepoint == 0) {
break;
}

if (!first) {
emojiHexCodeStream << separator;
}

Expand Down
Loading

0 comments on commit 6df823d

Please sign in to comment.