Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: v install vglyph
- name: Install C development dependencies (headers and libs)
if: runner.os == 'Linux'
run: v retry -- sudo apt -qq update && v retry -- sudo apt install libpango1.0-dev libfontconfig1-dev libfribidi-dev libharfbuzz-dev libfreetype-dev libgl1-mesa-dri xvfb libxcursor-dev libxi-dev libxrandr-dev freeglut3-dev
run: v retry -- sudo apt -qq update && v retry -- sudo apt install libpango1.0-dev libfontconfig1-dev libfribidi-dev libharfbuzz-dev libfreetype-dev libgl1-mesa-dri xvfb libxcursor-dev libxi-dev libxrandr-dev freeglut3-dev dbus libdbus-1-dev libdbus-glib-1-2 libdbus-glib-1-dev
- name: Install development dependencies on macos (headers and libs)
if: runner.os == 'macOS'
run: v retry -- brew install pango harfbuzz freetype2
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
run: v install vglyph
- name: Install X11/GL development dependencies (headers and libs)
if: runner.os == 'Linux'
run: v retry -- sudo apt -qq update && v retry -- sudo apt install libpango1.0-dev libfontconfig1-dev libfribidi-dev libharfbuzz-dev libfreetype-dev libgl1-mesa-dri xvfb libxcursor-dev libxi-dev libxrandr-dev freeglut3-dev
run: v retry -- sudo apt -qq update && v retry -- sudo apt install libpango1.0-dev libfontconfig1-dev libfribidi-dev libharfbuzz-dev libfreetype-dev libgl1-mesa-dri xvfb libxcursor-dev libxi-dev libxrandr-dev freeglut3-dev dbus libdbus-1-dev libdbus-glib-1-2 libdbus-glib-1-dev
- name: Install development dependencies on macos (headers and libs)
if: runner.os == 'macOS'
run: v retry -- brew install pango harfbuzz freetype2
Expand Down
22 changes: 20 additions & 2 deletions view_text_xtra.v
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module gui
//
import clipboard
import encoding.utf8
import os
import vglyph

// text_width calculates the width of a given text based on its style and window configuration,
Expand Down Expand Up @@ -418,21 +419,38 @@ fn collapse_spaces(text string) string {

// from_clipboard retrieves text content from the system clipboard and returns
// it as a string. Creates a temporary clipboard instance that is automatically
// freed after the paste operation completes.
// freed after the paste operation completes. Returns empty string if clipboard
// is unavailable.
pub fn from_clipboard() string {
$if !android && !ios {
if os.getenv('DISPLAY') == '' && os.getenv('WAYLAND_DISPLAY') == '' {
return ''
}
}
mut cb := clipboard.new()
defer { cb.free() }
if !cb.is_available() {
return ''
}
return cb.paste()
}

// to_clipboard copies the provided string to the system clipboard if a value
// is present. Creates a temporary clipboard instance that is automatically
// freed after the copy operation completes. Returns true if the copy operation
// was successful, false if the input was none.
// was successful, false if the input was none or clipboard unavailable.
pub fn to_clipboard(s ?string) bool {
if s != none {
$if !android && !ios {
if os.getenv('DISPLAY') == '' && os.getenv('WAYLAND_DISPLAY') == '' {
return false
}
}
mut cb := clipboard.new()
defer { cb.free() }
if !cb.is_available() {
return false
}
return cb.copy(s)
}
return false
Expand Down
Loading