From owner-svn-soc-all@FreeBSD.ORG Wed Jul 30 19:50:58 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 01DDC6B6 for ; Wed, 30 Jul 2014 19:50:58 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E14972C62 for ; Wed, 30 Jul 2014 19:50:57 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s6UJovVJ023447 for ; Wed, 30 Jul 2014 19:50:57 GMT (envelope-from pedrosouza@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s6UJovS1023444 for svn-soc-all@FreeBSD.org; Wed, 30 Jul 2014 19:50:57 GMT (envelope-from pedrosouza@FreeBSD.org) Date: Wed, 30 Jul 2014 19:50:57 GMT Message-Id: <201407301950.s6UJovS1023444@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to pedrosouza@FreeBSD.org using -f From: pedrosouza@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271623 - soc2014/pedrosouza/lua_loader/head/sys/boot/lua MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jul 2014 19:50:58 -0000 Author: pedrosouza Date: Wed Jul 30 19:50:56 2014 New Revision: 271623 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271623 Log: Added boot menu shortcuts Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua ============================================================================== --- soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua Wed Jul 30 18:47:31 2014 (r271622) +++ soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua Wed Jul 30 19:50:56 2014 (r271623) @@ -8,13 +8,16 @@ screen.setcursor(x, y); print("Boot Menu"); for k, v in pairs(opts) do - screen.setcursor(x, y + v.index); - local name = v.name; - - if (name == nil) then - name = v.getName(); + -- skip alias + if k ~= "alias" then + screen.setcursor(x, y + v.index); + local name = v.name; + + if (name == nil) then + name = v.getName(); + end + print(k .. " - " .. name); end - print(k .. " - " .. name); end end @@ -29,6 +32,7 @@ menu.drawbox(4, 10, 40, 10); drawer.drawbrand(); drawer.drawlogo(); + screen.defcursor(); local ch = string.char(io.getchar()); if (opts[ch] ~= nil) then local ret = opts[ch].func(); @@ -36,6 +40,17 @@ print("Exiting menu!\n"); return; end + else + --try alias key + if opts.alias ~= nil then + if opts.alias[ch] ~= nil then + local ret = opts.alias[ch].func(); + if (ret) then + print("Exiting menu!\n"); + return; + end + end + end end end end @@ -65,26 +80,39 @@ end menu.options = { - ["1"] = {index = 1, name = "Boot Multi user", func = function () core.setSingleUser(false); loader.perform("boot"); end}, - ["2"] = {index = 2, name = "Boot Single user", func = function () core.setSingleUser(true); loader.perform("boot"); end}, - ["3"] = {index = 3, name = "Escape to lua interpreter", func = function () return true; end}, - ["4"] = {index = 4, name = "Reboot", func = function () loader.perform("reboot"); end}, - ["5"] = {index = 5, name = "Boot Options", func = function () menu.run(boot_options); return false; end} + -- Boot multi user + ["1"] = {index = 1, name = color.highlight("B").."oot Multi user", func = function () core.setSingleUser(false); loader.perform("boot"); end}, + -- boot single user + ["2"] = {index = 2, name = "Boot "..color.highlight("S").."ingle user", func = function () core.setSingleUser(true); loader.perform("boot"); end}, + -- escape to interpreter + ["3"] = {index = 3, name = color.highlight("E").."scape to lua interpreter", func = function () return true; end}, + -- reboot + ["4"] = {index = 4, name = color.highlight("R").."eboot", func = function () loader.perform("reboot"); end}, + -- boot options + ["5"] = {index = 5, name = "Boot "..color.highlight("O").."ptions", func = function () menu.run(boot_options); return false; end} +}; + +menu.options.alias = { + ["b"] = menu.options["1"], + ["s"] = menu.options["2"], + ["e"] = menu.options["3"], + ["r"] = menu.options["4"], + ["o"] = menu.options["5"] }; function OnOff(str, b) if (b) then - return str .. color.escapef(color.GREEN)..": On"..color.escapef(color.WHITE); + return str .. color.escapef(color.GREEN).."On"..color.escapef(color.WHITE); else - return str .. color.escapef(color.RED)..": Off"..color.escapef(color.WHITE); + return str .. color.escapef(color.RED).."Off"..color.escapef(color.WHITE); end end boot_options = { ["1"] = {index = 1, name = "Back to menu", func = function () return true; end }, ["2"] = {index = 2, name = "Load System defaults", func = function () core.setDefaults(); return false; end }, - ["3"] = {index = 3, getName = function () return OnOff("ACPI ", core.acpi); end, func = function () core.setACPI(); return false; end }, - ["4"] = {index = 4, getName = function () return OnOff("Safe Mode ", core.sm); end, func = function () core.setSafeMode(); return false; end }, - ["5"] = {index = 5, getName = function () return OnOff("Single user", core.su); end, func = function () core.setSingleUser(); return false; end }, - ["6"] = {index = 6, getName = function () return OnOff("Verbose ", core.verbose); end, func = function () core.setVerbose(); return false; end } + ["3"] = {index = 3, getName = function () return OnOff("ACPI :", core.acpi); end, func = function () core.setACPI(); return false; end }, + ["4"] = {index = 4, getName = function () return OnOff("Safe Mode :", core.sm); end, func = function () core.setSafeMode(); return false; end }, + ["5"] = {index = 5, getName = function () return OnOff("Single user:", core.su); end, func = function () core.setSingleUser(); return false; end }, + ["6"] = {index = 6, getName = function () return OnOff("Verbose :", core.verbose); end, func = function () core.setVerbose(); return false; end } } \ No newline at end of file Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua ============================================================================== --- soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua Wed Jul 30 18:47:31 2014 (r271622) +++ soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua Wed Jul 30 19:50:56 2014 (r271623) @@ -32,6 +32,10 @@ return "\027[0;37;40m"; end +function color.highlight(str) + return "\027[1m"..str.."\027[0m"; +end + function screen.clear() print("\027[H\027[J"); end @@ -53,5 +57,5 @@ end function screen.defcursor() - print("\027[24;0H"); + print("\027[25;0H"); end \ No newline at end of file