Skip to content

Commit

Permalink
#116: adds linux handling where necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
rladstaetter committed Oct 26, 2022
1 parent f409845 commit ee72a9e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
8 changes: 0 additions & 8 deletions app/src/main/scala/app/logorrr/conf/SettingsIO.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ object SettingsIO extends CanLog {
/** turn off ugly 'hardcoded value' messages */
val renderOptions = ConfigRenderOptions.defaults().setOriginComments(false)

def updateDividerPosition(path: Path, dividerPosition: Double): Unit = {
LogoRRRGlobals.setDividerPosition(path.toAbsolutePath.toString, dividerPosition)
}

def updateActiveLogFile(path: Path): Unit = {
LogoRRRGlobals.setSomeActive(Option(path.toAbsolutePath.toString))
}

/** read settings from default place and filter all paths which don't exist anymore */
def fromFile(): Settings = {
val settingsFilePath = FilePaths.settingsFilePath
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/scala/app/logorrr/io/FilePaths.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package app.logorrr.io

import app.logorrr.util.OsUtil
import app.logorrr.util.OsUtil.{Mac, Os, Windows}
import app.logorrr.util.OsUtil.{Linux, Mac, Os, Windows}

import java.nio.file.{Path, Paths}

Expand Down Expand Up @@ -31,6 +31,7 @@ object FilePaths {
val confPath: Map[Os, Path] =
Map(Windows -> Paths.get("C:/ProgramData/LogoRRR/")
, Mac -> Paths.get(System.getProperty("user.home")).resolve("Library/Application Support/app.logorrr/")
, Linux -> Paths.get(System.getProperty("user.home")).resolve(".logorrr/")
)

val settingsFilePath: Path = confPath(OsUtil.currentOs).resolve(settingsFileName)
Expand Down
11 changes: 8 additions & 3 deletions app/src/main/scala/app/logorrr/util/OsUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,25 @@ object OsUtil {

case object Mac extends Os

case object Linux extends Os

val currentOs =
if (System.getProperty("os.name").toLowerCase.contains("windows")) {
Windows
} else {
} else if (System.getProperty("os.name").toLowerCase.contains("mac")) {
Mac
} else {
Linux
}

val isMac = currentOs == Mac
val isWin = currentOs == Windows
val isLinux = currentOs == Linux

def osFun[T](onWin : => T, onMac : => T) : T =
def osFun[T](onWin: => T, onMac: => T, onLinux: => T): T =
if (isWin) {
onWin
} else if (isMac) {
onMac
} else onMac // linux users have to wait for support of LogoRRR :(
} else onLinux
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ class SearchActivateRegexToggleButton
setTooltip(new Tooltip(
s"""activate regular expression search
|
|shortcut: ${OsUtil.osFun("CTRL-R", "COMMAND-R")}""".stripMargin))
|shortcut: ${OsUtil.osFun("CTRL-R", "COMMAND-R","CTRL-R")}""".stripMargin))

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import javafx.scene.control.{TextField, Tooltip}
class SearchTextField extends TextField {
setPrefWidth(200)
setMaxWidth(200)
setTooltip(new Tooltip(s"enter search pattern\n\nshortcut: ${OsUtil.osFun("CTRL-F", "COMMAND-F")}"))
setTooltip(new Tooltip(s"enter search pattern\n\nshortcut: ${OsUtil.osFun("CTRL-F", "COMMAND-F","CTRL-F")}"))

}

0 comments on commit ee72a9e

Please sign in to comment.