我目前正在尝试将this script更改为包含子菜单的菜单。 问题是如果我进入子菜单菜单没有完全清除。 它将主菜单的单行替换为子菜单的条目。
你知道我可以改变什么来使它运作吗?
这是我的上一个版本
#/bin/bash
E='echo -e';e='echo -en';trap "R;exit" 2
ESC=$( $e "\033")
TPUT(){ $e "\033[${1};${2}H";}
CL(){ $e "\033c";}
CIVIS(){ $e "\033[?25l";}
DRAW(){ $e "\033%@\033(0";}
WRITE(){ $e "\033(B";}
MARK(){ $e "\033[7m";}
UNMARK(){ $e "\033[27m";}
C(){ CL;}
i=0;CL;CIVIS;NULL=/dev/null
ARROW(){ read -s -n3 key 2>/dev/null >&2
if [[ $key = $ESC[A ]];then echo up;fi
if [[ $key = $ESC[B ]];then echo dn;fi;}
POSITION(){ if [[ $cur = up ]];then ((i--));fi
if [[ $cur = dn ]];then ((i++));fi
if [[ i -lt 0 ]];then i=$LM;fi
if [[ i -gt $LM ]];then i=0;fi;}
REFRESH(){ after=$((i+1)); before=$((i-1))
if [[ $before -lt 0 ]];then before=$LM;fi
if [[ $after -gt $LM ]];then after=0;fi
if [[ $j -lt $i ]];then UNMARK; M$before; else UNMARK; M$after;fi
if [[ $after -eq 0 ]] || [[ $before -eq $LM ]];then
UNMARK; M$before; M$after; fi; j=$i; UNMARK; M$before; M$after;}
M0(){ TPUT 3 4; $e "A) Firewall-Management & Gateway";}
M1(){ TPUT 4 4; $e "B) Bla bla bla";}
A0(){ TPUT 3 4; $e "1) Zweite Ebene";}
A1(){ TPUT 4 4; $e "2) Zweite Geile Ebene";}
MENU(){ LM=1; for each in $(seq 0 $LM);do M${each};done;}
INIT(){ MENU;}
SC(){ REFRESH;MARK;$S;cur=`ARROW`;}
ES(){ MARK;$e;read;INIT;};INIT
MENU2() {
REFRESH(){ after=$((i+1)); before=$((i-1))
if [[ $before -lt 0 ]];then before=$LM;fi
if [[ $after -gt $LM ]];then after=0;fi
if [[ $j -lt $i ]];then UNMARK; A$before; else UNMARK; A$after;fi
if [[ $after -eq 0 ]] || [[ $before -eq $LM ]];then
UNMARK; A$before; A$after; fi; j=$i; UNMARK; A$before; A$after;}
u_MENU() {
LM=1; for each in $(seq 0 $LM);do A${each};done;}
INIT(){ u_MENU;}
SC(){ REFRESH;MARK;$S;cur=`ARROW`;}
ES(){ MARK;$e;read;INIT;};INIT
while [[ "$O" != " " ]]; do case $i in
0) S=A0;SC;if [[ $cur = "" ]];then C; exit 0;fi;;
1) S=A1;SC;if [[ $cur = "" ]];then C; $e "a3:\n$(route -n )\n";ES;fi;;
esac;POSITION;done
}
while [[ "$O" != " " ]]; do case $i in
0) S=M0;SC;if [[ $cur = "" ]];then C; MENU2;ES;fi;;
1) S=M1;SC;if [[ $cur = "" ]];then C;exit 0;ES;fi;;
esac;POSITION;done
答案 0 :(得分:0)
1)
1
[wait 1 second]
2
[wait 1 second]
3
[wait 1 second]
4
[wait 1 second]
5
[wait 1 second]
6
[wait 1 second]
...
中的 function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var searchMenuEntries = [ {name: "Search in all files", functionName: "search"}];
ss.addMenu("Search Google Drive", searchMenuEntries);
}
function search() {
// Prompt the user for a search term
var searchTerm = Browser.inputBox("Enter the String to Search For:");
// Get the active spreadsheet and the active sheet
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
// Set up the spreadsheet to display the results
var headers = [["Unit 8 Project Data", "KU", "MI", "SE", "CO", "File Type", "URL"]];
sheet.clear();
sheet.getRange("A1:G1").setValues(headers);
// Search the files in the user's Google Drive for the search term
// See documentation for search parameters you can use
// https://developers.google.com/apps-script/reference/drive/drive-app#searchFiles(String)
var files = DriveApp.searchFiles("title contains
'"+searchTerm.replace("'","\'")+"'");
// create an array to store our data to be written to the sheet
var output = [];
// Loop through the results and get the file name, file type, and URL
while (files.hasNext()) {
var file = files.next();
var name = file.getName();
var startRow = 9; // First row of data to process
var numRows = 10; // Number of rows to process
var type = file.getMimeType();
var url = file.getUrl();
var id = file.getId();
var sheet = SpreadsheetApp.openById(id).getActiveSheet();
var dataRange = sheet.getRange(startRow, 6, numRows, 1)
var data = dataRange.getValues();
var KU = data[0][0];
var MI = data[3][0];
var SE = data[6][0];
var CO = data[9][0];
// push the file details to our output array (essentially pushing a row of data)
output.push([name, KU, MI, SE, CO, type, url]);
}
// write data to the sheet
sheet.getRange(2, 1, output.length, 7).setValues(output);
}
循环:
while
尝试将背景设置为蓝色。您会看到MENU2
似乎输出换行符。
2)
- esac;POSITION;C;done
+ esac;POSITION;done
来电C
/ REFRESH
/ M0
,因此我们需要在M1
中添加一个新的M2
来调用{{1}相反:} / REFRESH
/ MENU2
:
A0
答案 1 :(得分:0)
我想扩展脚本:
左箭头键和ESC键应取消命令,子菜单并返回主菜单。同样,它也应该离开主菜单。
你有这个特色吗?
我接下来试了一下
1)将ARROW-Function展开到
ARROW(){ read -s -n3 key 2>/dev/null >&2
if [[ $key = $ESC[A ]];then echo up;fi
if [[ $key = $ESC[B ]];then echo dn;fi
if [[ $key = $ESC[C ]];then echo lf;fi;}
2)将POSITION-Function展开到
POSITION(){ if [[ $cur = up ]];then ((i--));fi
21 if [[ $cur = dn ]];then ((i++));fi
22 if [[ $cur = lf ]];then break;fi
但那并不像我想象的那样有效; - )