mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-30 16:35:16 +08:00
Updated fish_config prompt tab
This commit is contained in:
parent
9e424ed921
commit
63233655f4
@ -390,18 +390,34 @@ img.delete_icon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.prompt_demo {
|
.prompt_demo {
|
||||||
/* This is the div that holds what the prompt looks like */
|
font-size: 12pt;
|
||||||
width: 100%;
|
padding: 25px;
|
||||||
background-color: black;
|
margin: 5px 20px 25px 20px; /* top right bottom left */
|
||||||
border-radius: 5px;
|
cursor: pointer;
|
||||||
display: table;
|
line-height: 1.8em;
|
||||||
|
border: solid #777 1px;
|
||||||
|
position: relative; /* so that our absolutely positioned elements work */
|
||||||
|
}
|
||||||
|
|
||||||
|
.prompt_demo_tight {
|
||||||
|
font-size: 10pt;
|
||||||
|
padding: 10px;
|
||||||
|
margin: 5px 20px 25px; /* top right bottom left */
|
||||||
|
cursor: pointer;
|
||||||
|
line-height: 1.8em;
|
||||||
|
border: solid #777 1px;
|
||||||
|
position: relative; /* so that our absolutely positioned elements work */
|
||||||
|
}
|
||||||
|
|
||||||
|
.prompt_demo_tight_selected {
|
||||||
|
border: solid #00ff00 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.save_button, .prompt_save_button {
|
.save_button, .prompt_save_button {
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
border: solid rgba(71,71,71,0.5) 1px;
|
border: solid rgba(71,71,71,0.5) 1px;
|
||||||
padding: 5px 8px;
|
padding: 5px 8px;
|
||||||
font-size: 12pt;
|
font-size: 10pt;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-top: 12px;
|
margin-top: 12px;
|
||||||
background-color: rgba(128,128,128,0.2);
|
background-color: rgba(128,128,128,0.2);
|
||||||
@ -412,7 +428,14 @@ img.delete_icon {
|
|||||||
.prompt_save_button:hover {
|
.prompt_save_button:hover {
|
||||||
background-color: #333;
|
background-color: #333;
|
||||||
border: solid #525252 1px;
|
border: solid #525252 1px;
|
||||||
color: #EEE;
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prompt_demo_choice_label {
|
||||||
|
margin: 5px 20px 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 12pt;
|
||||||
|
white-space: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.prompt_demo_text {
|
.prompt_demo_text {
|
||||||
@ -428,15 +451,19 @@ img.delete_icon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.prompt_function {
|
.prompt_function {
|
||||||
/* This is the div that holds the prompt function's definition */
|
display: block;
|
||||||
width: 100%;
|
border: 1px solid #555;
|
||||||
color: #BBB;
|
background-color: #181818;
|
||||||
font-size: 10pt;
|
margin: 5px 20px 25px;
|
||||||
|
border-radius: 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.prompt_function_text {
|
.prompt_function_text {
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
padding: 25px 3px;
|
padding: 15px 3px;
|
||||||
|
width: 100%;
|
||||||
|
height: 25%;
|
||||||
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.external_link_img {
|
.external_link_img {
|
||||||
|
@ -66,7 +66,6 @@ controllers.controller("colorsController", function($scope, $http) {
|
|||||||
for (name in settingNames) {
|
for (name in settingNames) {
|
||||||
var postData = "what=" + settingNames[name] + "&color=" + $scope.selectedColorScheme[settingNames[name]] + "&background_color=&bold=&underline=";
|
var postData = "what=" + settingNames[name] + "&color=" + $scope.selectedColorScheme[settingNames[name]] + "&background_color=&bold=&underline=";
|
||||||
$http.post("/set_color/", postData, { headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).success(function(data, status, headers, config) {
|
$http.post("/set_color/", postData, { headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).success(function(data, status, headers, config) {
|
||||||
console.log(data);
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -77,40 +76,27 @@ controllers.controller("colorsController", function($scope, $http) {
|
|||||||
controllers.controller("promptController", function($scope, $http) {
|
controllers.controller("promptController", function($scope, $http) {
|
||||||
$scope.selectedPrompt = null;
|
$scope.selectedPrompt = null;
|
||||||
|
|
||||||
$scope.fetchCurrentPrompt = function(currenttPrompt) {
|
|
||||||
$http.get("/current_prompt/").success(function(data, status, headers, config) {
|
|
||||||
currenttPrompt.function = data.function;
|
|
||||||
})};
|
|
||||||
|
|
||||||
$scope.fetchSamplePrompts= function() {
|
$scope.fetchSamplePrompts= function() {
|
||||||
$http.get("/sample_prompts/").success(function(data, status, headers, config) {
|
$http.get("/sample_prompts/").success(function(data, status, headers, config) {
|
||||||
$scope.samplePrompts = data;
|
$scope.samplePrompts = data;
|
||||||
|
$scope.samplePromptsArrayArray = get_colors_as_nested_array($scope.samplePrompts, 1);
|
||||||
|
|
||||||
if ($scope.selectedPrompt == null) {
|
if ($scope.selectedPrompt == null) {
|
||||||
$scope.selectPrompt($scope.samplePrompts[0]);
|
$scope.selectPrompt($scope.samplePrompts[0]);
|
||||||
}
|
}
|
||||||
})};
|
})};
|
||||||
|
|
||||||
$scope.fetchSamplePrompt = function(selectedPrompt) {
|
|
||||||
console.log("Fetcing sample prompt");
|
|
||||||
$http.post("/get_sample_prompt/","what=" + encodeURIComponent(selectedPrompt.function), { headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).success(function(data, status, headers, config) {
|
|
||||||
console.log("Data is " + JSON.stringify(data[0]));
|
|
||||||
$scope.demoText= data[0].demo;
|
|
||||||
$scope.demoTextFontSize = data[0].font_size;
|
|
||||||
console.log("Demo text is " + $scope.demoText);
|
|
||||||
})};
|
|
||||||
|
|
||||||
$scope.selectPrompt = function(promptt) {
|
$scope.selectPrompt = function(promptt) {
|
||||||
$scope.selectedPrompt= promptt;
|
$scope.selectedPrompt= promptt;
|
||||||
if ($scope.selectedPrompt.name == "Current") {
|
|
||||||
$scope.fetchCurrentPrompt($scope.selectedPrompt);
|
|
||||||
}
|
|
||||||
$scope.fetchSamplePrompt($scope.selectedPrompt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.setNewPrompt = function(selectedPrompt) {
|
$scope.setNewPrompt = function(selectedPrompt) {
|
||||||
console.log("Set new prompt" + selectedPrompt);
|
|
||||||
$http.post("/set_prompt/","what=" + encodeURIComponent(selectedPrompt.function), { headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).success(function(data, status, headers, config){
|
$http.post("/set_prompt/","what=" + encodeURIComponent(selectedPrompt.function), { headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).success(function(data, status, headers, config){
|
||||||
console.log("Data is " + JSON.stringify(data));
|
|
||||||
|
// Update attributes of current prompt
|
||||||
|
$scope.samplePrompts[0].demo = selectedPrompt.demo;
|
||||||
|
$scope.samplePrompts[0].function = selectedPrompt.function;
|
||||||
|
$scope.samplePrompts[0].font_size = selectedPrompt.font_size;
|
||||||
})};
|
})};
|
||||||
|
|
||||||
$scope.fetchSamplePrompts();
|
$scope.fetchSamplePrompts();
|
||||||
|
@ -9,3 +9,4 @@
|
|||||||
<div class="detail">
|
<div class="detail">
|
||||||
<div class="detail_function">{{ functionDefinition }}</div>
|
<div class="detail_function">{{ functionDefinition }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
@ -1,25 +1,17 @@
|
|||||||
<div id="master_detail_table" style="display: table;">
|
<div style="padding: 0 10px 15px;">
|
||||||
<div id="master">
|
|
||||||
<div ng-repeat="prompt in samplePrompts">
|
|
||||||
<div id="master_{{prompt.name}}" ng-class="{'master_element': true, 'selected_master_elem': selectedPrompt == prompt}" ng-style="prompt.name=='Current' && {color: '#6666ff'} || {color: '#aaaaaa' }" ng-click="selectPrompt(prompt)">
|
|
||||||
<span ng-class="{master_element_text: selectedPrompt == prompt}" ng-style="prompt.name=='Current' && {'font-size': '13pt', 'border-bottom-color': rgb(0, 6, 111) } || {'font-size': '13pt'}">{{ prompt.name }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="detail">
|
|
||||||
<div id="detail_prompt" style="display: block;">
|
|
||||||
<div class="prompt_demo">
|
<div class="prompt_demo">
|
||||||
<div class="prompt_demo_text" style="font-size: {{ demoTextFontSize }};" ng-bind-html-unsafe="demoText">
|
<div ng-bind-html-unsafe="selectedPrompt.demo"></div>
|
||||||
</div>
|
<span class="prompt_save_button" style="position: absolute; right: 2px; bottom: 2px;" ng-click="setNewPrompt(selectedPrompt)" ng-hide="selectedPrompt == samplePrompts[0]">Use</span>
|
||||||
</div>
|
|
||||||
<div style="text-align: right" ng-show="selectedPrompt.name != 'Current'">
|
|
||||||
<span class="prompt_save_button" ng-click="setNewPrompt(selectedPrompt)"> use prompt </span>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="prompt_function">
|
<div class="prompt_function">
|
||||||
<div class="prompt_function_text">
|
<div class="prompt_function_text">{{ selectedPrompt.function }}</div>
|
||||||
{{ selectedPrompt.function }}
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
<div>
|
||||||
|
<div ng-repeat="prompt in samplePrompts" ng-click="selectPrompt(prompt)">
|
||||||
|
<div class="prompt_demo_choice_label">{{ prompt.name }}</div>
|
||||||
|
<div ng-bind-html-unsafe='prompt.demo' ng-class="{'prompt_demo_tight': true, 'prompt_demo_tight_selected': prompt == selectedPrompt}"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -534,7 +534,7 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
|||||||
if len(comps) < 3:
|
if len(comps) < 3:
|
||||||
continue
|
continue
|
||||||
if comps[1] == '-k':
|
if comps[1] == '-k':
|
||||||
key_name, command = comps[2].split(' ', 2)
|
key_name, command = comps[2].split(' ', 1)
|
||||||
binding_parser.set_buffer(key_name, True)
|
binding_parser.set_buffer(key_name, True)
|
||||||
fish_binding = FishBinding(command=command, binding=key_name, readable_binding=binding_parser.get_readable_binding())
|
fish_binding = FishBinding(command=command, binding=key_name, readable_binding=binding_parser.get_readable_binding())
|
||||||
else:
|
else:
|
||||||
@ -629,13 +629,15 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
|||||||
# Maybe not we're not parsing hashes, or maybe we already were not
|
# Maybe not we're not parsing hashes, or maybe we already were not
|
||||||
if not parsing_hashes:
|
if not parsing_hashes:
|
||||||
function_lines.append(line)
|
function_lines.append(line)
|
||||||
result['function'] = ''.join(function_lines).strip()
|
func = ''.join(function_lines).strip()
|
||||||
|
result.update(self.do_get_sample_prompt(func))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def do_get_sample_prompts_list(self):
|
def do_get_sample_prompts_list(self):
|
||||||
result = []
|
result = []
|
||||||
# Start with the "Current" meta-sample
|
# Start with the "Current" meta-sample
|
||||||
result.append({'name': 'Current'})
|
result.append({'name': 'Current'})
|
||||||
|
result[0].update(self.do_get_current_prompt())
|
||||||
|
|
||||||
# Read all of the prompts in sample_prompts
|
# Read all of the prompts in sample_prompts
|
||||||
paths = glob.iglob('sample_prompts/*.fish')
|
paths = glob.iglob('sample_prompts/*.fish')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user