diff --git a/web_config/index.html b/web_config/index.html index b35f35bb3..7d6e0d400 100644 --- a/web_config/index.html +++ b/web_config/index.html @@ -94,10 +94,15 @@ body { } .data_table_cell { - padding-bottom: 10px; + padding-top: 5px; + padding-bottom: 5px; overflow:hidden; + border-bottom: #444 dotted 1px; +} + +.no_overflow { text-overflow: ellipsis; - white-space: nowrap; + white-space: nowrap; } .colorpicker_term256_row { @@ -146,6 +151,7 @@ function switch_tab(new_tab) { /* Hide some things */ $('#colorpicker_term256').hide() $('#data_table').hide() + $('#data_table').empty() /* Load something new */ if (new_tab == 'tab_colors') { @@ -169,7 +175,10 @@ function switch_tab(new_tab) { }) $('#data_table').show() } else if (new_tab == 'tab_history') { - + run_get_request('/history/', function(contents){ + create_data_table_element([contents]) + }) + $('#data_table').show() } else { alert("Unknown tab"); } @@ -225,23 +234,39 @@ function create_master_element(contents) { ).appendTo('#master') } +/* Toggle the no_overflow class */ +function toggle_overflow(who) { + $(who).toggleClass('no_overflow') +} + /* Creates a new row in the data table */ function create_data_table_element(contents_list) { var row = $('', { class: 'data_table_row' }) for (idx = 0; idx < contents_list.length; idx++) { - /* Align the first one right, subsequent ones left */ - if (idx == 0) { - cell_style = 'text-align: right; padding-right: 30px;' + /* If we have more than one, then align the first one right, subsequent ones left */ + if (idx == 0 && contents_list.length > 1) { + cell = $('', { + class: 'data_table_cell no_overflow', + style: 'text-align: right; padding-right: 30px;' + }); + } else { - cell_style = 'text-align: left;' + cell = $('', { + class: 'data_table_cell no_overflow', + style: 'text-align: left', + onClick: "toggle_overflow(this)" + }); } - row.append($('', { - class: 'data_table_cell', - style: cell_style, - text: contents_list[idx] - })) + text_list = contents_list[idx].split("\n") + for (j=0; j < text_list.length; j++) { + cell.append($('

', { + text: text_list[j] + })) + } + + row.append(cell) } $('#data_table').append(row) } @@ -282,10 +307,10 @@ $(document).ready(function() { fish

-
colors
-
functions
-
variables
-
history
+
colors
+
functions
+
variables
+
history
diff --git a/web_config/webconfig.py b/web_config/webconfig.py index 0d87241a0..e9a50d4b6 100755 --- a/web_config/webconfig.py +++ b/web_config/webconfig.py @@ -55,7 +55,7 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): return out.split('\n') def do_get_variables(self): - out, err = run_fish_cmd('set') + out, err = run_fish_cmd('set -L') # Put all the variables into a dictionary vars = {} @@ -65,15 +65,20 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): fish_var = FishVar(comps[0], comps[1]) vars[fish_var.name] = fish_var - # Mark universal variables - for name in self.do_get_variable_names('set -nU'): + # Mark universal variables. L means don't abbreviate. + for name in self.do_get_variable_names('set -nUL'): if name in vars: vars[name].universal = True - # Mark exported variables - for name in self.do_get_variable_names('set -nx'): + # Mark exported variables. L means don't abbreviate. + for name in self.do_get_variable_names('set -nxL'): if name in vars: vars[name].exported = True return [vars[key].get_json_obj() for key in sorted(vars.keys(), key=str.lower)] - + + def do_get_history(self): + # Use \x1e ("record separator") to distinguish between history items. The first + # backslash is so Python passes one backslash to fish + out, err = run_fish_cmd('for val in $history; echo -n $val \\x1e; end') + return out.split('\x1e') def do_get_color_for_variable(self, name): @@ -89,6 +94,8 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): output = self.do_get_functions() elif p == '/variables/': output = self.do_get_variables() + elif p == '/history/': + output = self.do_get_history() elif re.match(r"/color/(\w+)/", p): name = re.match(r"/color/(\w+)/", p).group(1) output = self.do_get_color_for_variable(name) @@ -101,8 +108,6 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): self.wfile.write('\n') # Output JSON - print len(output) - print output json.dump(output, self.wfile)