VizCommand #35 walkコマンドでフォルダの移動

linuxコマンドのcdに相当するフォルダ移動コマンドwalkを実装する。

Console.hで、

Consoleオブジェクトが生成された時のデフォルトカレントパスとしてm_tstrDefaultCurrentPathを用意。
コンストラクタもtstrDefaultCurrentPathを引数に取るものを追加。
そしてOnWalkハンドラを追加。

Console.cppは、

コンストラクタでm_tstrDefaultCurrentPathにtstrDefaultCurrentPathを入れる。

OnCreateでは、pConsoleCore->SetCurrentPathでm_tstrDefaultCurrentPathをセットする。

OnConsoleCoreCommandで"walk"と入力されたらOnWalkを呼ぶようにする。

OnWalkでは、パラメータのtstrPathがなければ、pConsoleCore->GetMyDocumentPathでマイドキュメントのパスを取得してtstrPathに入れる。
tstrPathがある場合は、絶対パスに変換。
pConsoleCore->SetCurrentPathでtstrPathをカレントパスにセット。
pConsoleCore->GetOutputFormStringでフォーム文字列を更新して、UM_FINISHRESPONSEでレスポンス処理終了。

ConsoleCore.cppでは、

カレントパスが無い場合はマイドキュメントをカレントパスとするようにする。
つまり、カレントパスが指定されていたら、そのままにする。

StreamConsole.cppでは、

listの前のpConsoleCore->GetCurrentPathでカレントパスをtstrCurrentPathに保持しておき、listの後に挿入するCConsoleのコンストラクタにtstrCurrentPathを渡す。
これで新しいConsoleでもカレントパスが保持される。

f:id:BG1:20170606125558p:plain

walkにパラメータが無い場合は、

f:id:BG1:20170606125646p:plain

変わらない。

f:id:BG1:20170606125736p:plain

".."で、

f:id:BG1:20170606125800p:plain

上のフォルダに移動。

f:id:BG1:20170606125859p:plain

ここでパラメータ無しのwalkで、

f:id:BG1:20170606125930p:plain

マイドキュメントに戻ってきた。

f:id:BG1:20170606130006p:plain

testフォルダに移動。

f:id:BG1:20170606130031p:plain

testにきた。

f:id:BG1:20170606130314p:plain

ここでlistコマンドを打つと、

f:id:BG1:20170606130337p:plain

testフォルダの一覧を表示し、次のConsoleのカレントパスもtestになっている。

f:id:BG1:20170606130439p:plain

walkで上に移動。

f:id:BG1:20170606130510p:plain

listでマイドキュメント表示。

・walkコマンドでフォルダの移動 · bg1bgst333/VizCommand@9429b94 · GitHub