
###############################################################################
# ディレクトリメニュー
###############################################################################
$directory_menu = [
    ["(1) " + ENV['HOME'] + "/tmp/", KEY_1, ENV['HOME'] + "/tmp/"], 
    ["(2) " + "/etc", KEY_2, "/etc/"]
]

def directory_menu()
    menu_array = []
    $directory_menu.each() {|item|
        menu_array.push(item[0])
        menu_array.push(item[1])
        menu_array.push("dir_move adir(), '#{item[2]}'")
    }

    menu_array.push("----------------------------------------")
    menu_array.push(KEY_CTRL_Z)
    menu_array.push("")

    menu_array.push("(A)dd currenct path to jump menu")
    menu_array.push(KEY_A)
    menu_array.push("add_current_path_to_directory_menu()")

    menu_array.push("(D)elete jump menu")
    menu_array.push(KEY_D)
    menu_array.push("del_directory_menu()")

    menu_array.push("(C)lear jump menu")
    menu_array.push(KEY_C)
    menu_array.push("clear_directory_menu()")

    defmenu('jump', *menu_array )
    menu('jump')
end

def add_directory_menu(title, key)
    $directory_menu.push([title, key, adir_path()])
end

def del_directory_menu()
    menu_array = []
    n = 0
    $directory_menu.each() {|item|
        menu_array.push(item[0])
        menu_array.push(item[1])
        menu_array.push("$directory_menu.delete_at #{n}")
        n += 1
    }
    defmenu( 'delete_directory_menu', *menu_array )
    menu('delete_directory_menu')
end

def clear_directory_menu()
    $directory_menu = []
end

def save_directory_menu(f)
    f.puts $directory_menu.size

    $directory_menu.each() {|item|
        f.puts item[0]
        f.puts item[1]
        f.puts item[2]
    }
end

def read_directory_menu(f)
    $directory_menu = []

    size = f.readline.chomp!.to_i
    
    i = 0
    while i < size
        array = []
        line = f.readline.chomp!
        array.push(line)
        line = f.readline.chomp!
        array.push(line.to_i)
        line = f.readline.chomp!
        array.push(line)

        $directory_menu.push(array)

        i += 1
    end
end


