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
3 changes: 3 additions & 0 deletions src/windy/platforms/emscripten/platform.nim
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,9 @@ proc `onDownloadProgress=`*(handle: HttpRequestHandle, callback: HttpProgressCal
if state == nil: return
state.onDownloadProgress = callback

proc getConfigHome*(appName: string): string =
raise newException(Exception, "getConfigHome is not supported on emscripten")

proc openTempTextFile*(title, text: string) =
## Open a new tab in the browser.
open_temp_text_file(title.cstring, text.cstring)
Expand Down
11 changes: 10 additions & 1 deletion src/windy/platforms/linux/x11.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import
std/[os, sequtils, sets, strformat, strutils, times, unicode, uri],
std/[os, sequtils, sets, strformat, strutils, times, unicode, uri, pathnorm],
../../[common, internal],
vmath, pixie,
x11/[glx, keysym, x, xevent, xlib, xcursor]
Expand Down Expand Up @@ -1327,6 +1327,15 @@ proc url*(window: Window): string =
## Url cannot be gotten on linux.
warn "Url cannot be gotten on linux"

proc getConfigHome*(appName: string): string =
## Returns the platform-appropriate user config directory for the given app name.
## For Linux: Honors XDG_CONFIG_HOME, defaults to ~/.config/<appName>.
let xdgConfigHome = getEnv("XDG_CONFIG_HOME")
if xdgConfigHome != "":
result = (xdgConfigHome / appName).normalizePath
else:
result = (getHomeDir() / ".config" / appName).normalizePath

proc openUrl*(url: string) =
## Open a URL in the default browser.
discard execShellCmd("xdg-open " & url)
Expand Down
7 changes: 6 additions & 1 deletion src/windy/platforms/macos/platform.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import
std/[os, times, unicode],
std/[os, times, unicode, pathnorm],
opengl, pixie/fileformats/png, pixie/images, utils, vmath,
../../[common, internal], macdefs

Expand Down Expand Up @@ -1094,6 +1094,11 @@ proc getScreens*(): seq[Screen] =
primary: i == 0
)

proc getConfigHome*(appName: string): string =
## Returns the platform-appropriate user config directory for the given app name.
## For macOS: Returns ~/Library/Application Support/<appName>.
result = (getHomeDir() / "Library" / "Application Support" / appName).normalizePath

proc openTempTextFile*(title, text: string) =
## Open a text file in the default text editor.
if not dirExists("tmp"):
Expand Down
7 changes: 6 additions & 1 deletion src/windy/platforms/win32/platform.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import
std/[os, times, unicode, strutils, tables],
std/[os, times, unicode, strutils, tables, pathnorm],
../../[common, internal], flatty/binny, pixie/fileformats/png,
pixie/fileformats/bmp, pixie/images,
urlly, utils, vmath, windefs, zippy
Expand Down Expand Up @@ -2492,6 +2492,11 @@ proc forceButtonReleased*(window: Window, button: Button) =
## This is used for simulating UI tests.
window.handleButtonRelease(button)

proc getConfigHome*(appName: string): string =
## Returns the platform-appropriate user config directory for the given app name.
## For Windows: Returns %APPDATA%\<appName>.
result = (getEnv("APPDATA") / appName).normalizePath

proc openTempTextFile*(title, text: string) =
## Open a text file in the default text editor.
if not dirExists("tmp"):
Expand Down