Skip to content

Commit

Permalink
Adds OpenCommandLine command.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattstermiller committed Mar 18, 2017
1 parent 3b12918 commit 48597f3
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Koffee/FileSystemService.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type IFileSystemService =
abstract Delete: Path -> unit
abstract OpenFile: Path -> unit
abstract OpenExplorer: Path -> unit
abstract OpenCommandLine: Path -> unit

type FileSystemService() =
let wpath (path: Path) = path.Format Windows
Expand All @@ -38,6 +39,7 @@ type FileSystemService() =
override this.Delete node = this.Delete node
override this.OpenFile path = this.OpenFile path
override this.OpenExplorer path = this.OpenExplorer path
override this.OpenCommandLine path = this.OpenCommandLine path

member this.GetNode path =
let wp = wpath path
Expand Down Expand Up @@ -150,6 +152,10 @@ type FileSystemService() =
if path <> Path.Root then
Process.Start("explorer.exe", String.Format("/select,\"{0}\"", wpath path)) |> ignore

member this.OpenCommandLine path =
if path <> Path.Root then
Process.Start("cmd.exe", String.Format("/k pushd \"{0}\"", wpath path)) |> ignore


member private this.FileNode file = {
Path = toPath file.FullName
Expand Down
1 change: 1 addition & 0 deletions Koffee/KeyBinding.fs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ let DefaultsAsString = [
("<s-delete>", PromptDelete)
("<f9>", TogglePathFormat)
("<c-e>", OpenExplorer)
("<cs-c>", OpenCommandLine)
("?", OpenSettings)
("<f1>", OpenSettings)
("<c-w>", Exit)
Expand Down
6 changes: 6 additions & 0 deletions Koffee/MainController.fs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type MainController(fileSys: IFileSystemService, settingsFactory: unit -> Mvc<Se
| TogglePathFormat -> Sync this.TogglePathFormat
| OpenSettings -> Sync this.OpenSettings
| OpenExplorer -> Sync this.OpenExplorer
| OpenCommandLine -> Sync this.OpenCommandLine
| Exit -> Sync ignore // handled by view

member this.OpenUserPath pathStr model =
Expand Down Expand Up @@ -400,6 +401,11 @@ type MainController(fileSys: IFileSystemService, settingsFactory: unit -> Mvc<Se
fileSys.OpenExplorer model.SelectedNode.Path
model.Status <- Some <| MainStatus.openExplorer model.PathFormatted

member this.OpenCommandLine model =
if model.Path <> Path.Root then
fileSys.OpenCommandLine model.Path
model.Status <- Some <| MainStatus.openCommandLine model.PathFormatted

member this.OpenSettings model =
let settings = settingsFactory()
settings.StartDialog() |> ignore
Expand Down
3 changes: 3 additions & 0 deletions Koffee/MainModel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ type MainEvents =
| Redo
| TogglePathFormat
| OpenExplorer
| OpenCommandLine
| OpenSettings
| Exit

Expand Down Expand Up @@ -223,6 +224,7 @@ type MainEvents =
| Redo -> "Redo Action"
| TogglePathFormat -> "Toggle Between Windows and Unix Path Format"
| OpenExplorer -> "Open Windows Explorer at Current Location"
| OpenCommandLine -> "Open Windows Commandline at Current Location"
| OpenSettings -> "Open Help/Settings"
| Exit -> "Exit"

Expand Down Expand Up @@ -259,6 +261,7 @@ type MainEvents =
Redo
TogglePathFormat
OpenExplorer
OpenCommandLine
OpenSettings
Exit
]
1 change: 1 addition & 0 deletions Koffee/MainView.fs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ module MainStatus =
let changePathFormat newFormat = Message <| sprintf "Changed Path Format to %O" newFormat
let openFile path = Message <| sprintf "Opened File: %s" path
let openExplorer path = Message <| sprintf "Opened Windows Explorer to: %s" path
let openCommandLine path = Message <| sprintf "Opened Commandline at: %s" path

let private runningActionMessage action pathFormat =
match action with
Expand Down
2 changes: 1 addition & 1 deletion Koffee/SettingsWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Koffee Settings" Width="600" Height="650">
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Koffee Settings" Width="650" Height="750">
<Grid>
<Label x:Name="label" Content="Key Bindings:" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Top"/>
<DataGrid x:Name="KeyBindings" Margin="0,26,0,10" CanUserResizeRows="False" AreRowDetailsFrozen="True" GridLinesVisibility="None" AlternatingRowBackground="#FFEAEAEA" FontSize="13" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" ColumnWidth="*" AutoGenerateColumns="False" IsReadOnly="True">
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ _Capitalized letters indicate that the key is combined with Shift._

#### Other
- Open Windows Explorer at your current location with `Ctrl + e`
- Open Commandline at your current location with `Ctrl + Shift + c`
- Toggle between Windows-style and Unix-style path formats with `F9`

## Version History
Expand Down

0 comments on commit 48597f3

Please sign in to comment.