mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 12:04:39 +08:00
webconfig: Remove the abbreviations tab
Since the new expanded abbreviations in 3.6.0, abbr no longer accepts new universal variables. That means this tab is now non-functional (except that it could technically remove abbrs that were set in universal variables). Because making it work with the expanded abbreviations requires some awkwardness like a dedicated conf.d snippet (or writing into config.fish!), we simply remove it.
This commit is contained in:
parent
1d29ae7847
commit
4ceb497bfb
|
@ -293,19 +293,6 @@ body {
|
|||
border-bottom: #444 dotted 1px;
|
||||
}
|
||||
|
||||
.abbreviation_actions {
|
||||
width: 8em;
|
||||
text-align: right;
|
||||
border-bottom: #444 dotted 1px;
|
||||
}
|
||||
|
||||
.abbreviation_input {
|
||||
height: 1.5em;
|
||||
font: inherit;
|
||||
padding: 3px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* The CSS we apply when a table row is filtered */
|
||||
.data_table_row_filtered {
|
||||
display: none;
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
<div ng-class="{'tab': true, 'selected_tab': currentTab == 'variables'}" id="tab_variables" ng-click="changeView('variables')">variables</div>
|
||||
<div ng-class="{'tab': true, 'selected_tab': currentTab == 'history'}" id="tab_history" ng-click="changeView('history')">history</div>
|
||||
<div ng-class="{'tab': true, 'selected_tab': currentTab == 'bindings'}" id="tab_bindings" ng-click="changeView('bindings')">bindings</div>
|
||||
<div ng-class="{'tab': true, 'selected_tab': currentTab == 'abbreviations'}" id="tab_abbreviations" ng-click="changeView('abbreviations')">abbreviations</div>
|
||||
</div>
|
||||
<div id="tab_contents">
|
||||
<ng-view></ng-view>
|
||||
|
|
|
@ -34,10 +34,6 @@ fishconfig.config(
|
|||
controller: "bindingsController",
|
||||
templateUrl: "partials/bindings.html"
|
||||
})
|
||||
.when("/abbreviations", {
|
||||
controller: "abbreviationsController",
|
||||
templateUrl: "partials/abbreviations.html"
|
||||
})
|
||||
.otherwise({
|
||||
redirectTo: "/colors"
|
||||
})
|
||||
|
|
|
@ -395,49 +395,3 @@ controllers.controller("bindingsController", function($scope, $http) {
|
|||
|
||||
$scope.fetchBindings();
|
||||
});
|
||||
|
||||
controllers.controller("abbreviationsController", function($scope, $http) {
|
||||
$scope.abbreviations = [];
|
||||
$scope.addBlank = function() {
|
||||
// Add blank entry if it is missing
|
||||
var hasBlank = {hasBlank: false}
|
||||
angular.forEach($scope.abbreviations, function(value, key) {
|
||||
if (value.phrase === "" && value.word === "") {
|
||||
this.hasBlank = true;
|
||||
}
|
||||
}, hasBlank);
|
||||
if (!$scope.abbreviations) $scope.abbreviations = [];
|
||||
if (! hasBlank.hasBlank) {
|
||||
$scope.abbreviations.push({phrase: "", word: "", editable: true})
|
||||
}
|
||||
}
|
||||
$scope.fetchAbbreviations = function() {
|
||||
$http.get("abbreviations/").then(function(arg) {
|
||||
$scope.abbreviations = arg.data;
|
||||
$scope.addBlank();
|
||||
})};
|
||||
|
||||
$scope.editAbbreviation = function(abbreviation) {
|
||||
abbreviation.editable = true;
|
||||
}
|
||||
|
||||
$scope.saveAbbreviation = function(abbreviation) {
|
||||
if (abbreviation.word && abbreviation.phrase) {
|
||||
$http.post("save_abbreviation/", abbreviation).then(function(arg) {
|
||||
abbreviation.editable = false;
|
||||
$scope.addBlank();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.removeAbbreviation = function(abbreviation) {
|
||||
if (abbreviation.word) {
|
||||
$http.post("remove_abbreviation/", abbreviation).then(function(arg) {
|
||||
$scope.abbreviations.splice($scope.abbreviations.indexOf(abbreviation), 1);
|
||||
$scope.addBlank();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.fetchAbbreviations();
|
||||
});
|
||||
|
|
|
@ -41,20 +41,3 @@ filters.filter("filterBinding", function() {
|
|||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
filters.filter("filterAbbreviations", function() {
|
||||
return function(abbreviations, query) {
|
||||
var result = []
|
||||
if (abbreviations == undefined) return result;
|
||||
if (query == null) { return abbreviations};
|
||||
|
||||
for(var i=0; i<abbreviations.length; ++i) {
|
||||
var abbr = abbreviations[i];
|
||||
if (abbr.word.toLowerCase().indexOf(query) != -1 || abbr.phrase.toLowerCase().indexOf(query.toLowerCase()) != -1) {
|
||||
result.push(abbr);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
<div id="table_filter_container" style="display: block;">
|
||||
<input id="table_filter_text_box" class="filter_text_box text_box_transient" placeholder="Filter" ng-model="query">
|
||||
</div>
|
||||
|
||||
<table class="data_table">
|
||||
<tbody>
|
||||
<tr class="data_table_row" ng-repeat="abbreviation in abbreviations | filterAbbreviations:query" ng-click="editAbbreviation(abbreviation)">
|
||||
<td ng-class="{ data_table_cell: true }" style="text-align: right; padding-right: 30px;">
|
||||
<span ng-hide="abbreviation.editable">{{ abbreviation.word }}</span>
|
||||
<span ng-show="abbreviation.editable"><input ng-model="abbreviation.word" class="abbreviation_input" style="text-align: right; min-width: 10em;"></span>
|
||||
</td>
|
||||
<td ng-class="{ data_table_cell: true }" style="text-align: left; padding-right: 30px;">
|
||||
<span ng-hide="abbreviation.editable">{{ abbreviation.phrase }}</span>
|
||||
<span ng-show="abbreviation.editable"><input ng-model="abbreviation.phrase" class="abbreviation_input" style="text-align: left; min-width: 22em;"></span>
|
||||
</td>
|
||||
<td ng-class="{ data_table_cell: true }" class="abbreviation_actions">
|
||||
<span ng-show="abbreviation.editable && abbreviation.word && abbreviation.phrase" ng-click="saveAbbreviation(abbreviation)"><button class="save_button" style="margin: inherit;">Save</button></span>
|
||||
<a ng-show="abbreviation.word" ng-click="removeAbbreviation(abbreviation)"><img alt="Delete" src="delete.png" style="vertical-align: text-bottom"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
|
@ -1338,40 +1338,6 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
|||
result.extend([self.read_one_sample_prompt(path) for path in paths])
|
||||
return result
|
||||
|
||||
def do_get_abbreviations(self):
|
||||
# Example abbreviation line:
|
||||
# abbr -a -U -- ls 'ls -a'
|
||||
result = []
|
||||
out, err = run_fish_cmd("abbr --show")
|
||||
for line in out.rstrip().split("\n"):
|
||||
if not line:
|
||||
continue
|
||||
_, abbr = line.split(" -- ", 1)
|
||||
word, phrase = abbr.split(" ", 1)
|
||||
result.append({"word": word, "phrase": phrase})
|
||||
return result
|
||||
|
||||
def do_remove_abbreviation(self, abbreviation):
|
||||
out, err = run_fish_cmd("abbr --erase %s" % abbreviation["word"])
|
||||
if err:
|
||||
return err
|
||||
else:
|
||||
return None
|
||||
|
||||
def do_save_abbreviation(self, abbreviation):
|
||||
out, err = run_fish_cmd(
|
||||
# Remove one layer of single-quotes because escape_fish_cmd adds them back.
|
||||
"abbr --add %s %s"
|
||||
% (
|
||||
escape_fish_cmd(strip_one_layer(abbreviation["word"], "'")),
|
||||
escape_fish_cmd(strip_one_layer(abbreviation["phrase"], "'")),
|
||||
)
|
||||
)
|
||||
if err:
|
||||
return err
|
||||
else:
|
||||
return None
|
||||
|
||||
def secure_startswith(self, haystack, needle):
|
||||
if len(haystack) < len(needle):
|
||||
return False
|
||||
|
@ -1453,8 +1419,6 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
|||
output = self.do_get_color_for_variable(name)
|
||||
elif p == "/bindings/":
|
||||
output = self.do_get_bindings()
|
||||
elif p == "/abbreviations/":
|
||||
output = self.do_get_abbreviations()
|
||||
else:
|
||||
return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
|
||||
|
||||
|
@ -1577,18 +1541,6 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
|||
output = ["OK"]
|
||||
else:
|
||||
output = ["Unable to set prompt"]
|
||||
elif p == "/save_abbreviation/":
|
||||
errmsg = self.do_save_abbreviation(postvars)
|
||||
if errmsg:
|
||||
output = [errmsg]
|
||||
else:
|
||||
output = ["OK"]
|
||||
elif p == "/remove_abbreviation/":
|
||||
errmsg = self.do_remove_abbreviation(postvars)
|
||||
if errmsg:
|
||||
output = [errmsg]
|
||||
else:
|
||||
output = ["OK"]
|
||||
else:
|
||||
return self.send_error(404)
|
||||
|
||||
|
@ -1701,7 +1653,6 @@ if len(sys.argv) > 1:
|
|||
"variables",
|
||||
"history",
|
||||
"bindings",
|
||||
"abbreviations",
|
||||
]:
|
||||
if tab.startswith(sys.argv[1]):
|
||||
initial_tab = "#!/" + tab
|
||||
|
|
Loading…
Reference in New Issue
Block a user