From a11687fc5c984a18d1d2071c1f88d0a12c5b2f5d Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 25 Mar 2012 22:41:22 -0700 Subject: [PATCH] Make the functions builtin have a bit nicer output Stop autosuggesting things with newlines Make webconfig a little nicer --- builtin.cpp | 14 ++- reader.cpp | 7 +- share/tools/web_config/index.html | 129 +++++++++++++++++----------- share/tools/web_config/webconfig.py | 2 + 4 files changed, 98 insertions(+), 54 deletions(-) diff --git a/builtin.cpp b/builtin.cpp index a48403602..500484076 100644 --- a/builtin.cpp +++ b/builtin.cpp @@ -1081,7 +1081,7 @@ static int builtin_generic( parser_t &parser, wchar_t **argv ) /** Output a definition of the specified function to the specified - stringbuffer. Used by the functions builtin. + string. Used by the functions builtin. */ static void functions_def( const wcstring &name, wcstring &out ) { @@ -1167,8 +1167,16 @@ static void functions_def( const wcstring &name, wcstring &out ) } } - - append_format( out, L"\n\t%ls\nend\n", def ); + + /* This forced tab is sort of crummy - not all functions start with a tab */ + append_format( out, L"\n\t%ls", def); + + /* Append a newline before the end, unless there already is one there */ + size_t deflen = wcslen(def); + if (deflen == 0 || def[deflen-1] != L'\n') { + out.push_back(L'\n'); + } + out.append(L"end\n"); } diff --git a/reader.cpp b/reader.cpp index b645c2b07..003795479 100644 --- a/reader.cpp +++ b/reader.cpp @@ -1256,6 +1256,7 @@ struct autosuggestion_context_t { { } + /* The function run in the background thread to determine an autosuggestion */ int threaded_autosuggest(void) { ASSERT_IS_BACKGROUND_THREAD(); @@ -1265,6 +1266,11 @@ struct autosuggestion_context_t { while (searcher.go_backwards()) { history_item_t item = searcher.current_item(); + + /* Skip items with newlines because they make terrible autosuggestions */ + if (item.str().find('\n') != wcstring::npos) + continue; + bool item_ok = false; if (autosuggest_handle_special(item.str(), working_directory, &item_ok)) { /* The command autosuggestion was handled specially, so we're done */ @@ -3079,7 +3085,6 @@ const wchar_t *reader_readline() if( ! data->command_line.empty() ) { if (data->history) { - //data->history->add(data->command_line); data->history->add_with_file_detection(data->command_line); } } diff --git a/share/tools/web_config/index.html b/share/tools/web_config/index.html index 4ab8a03c7..904cab1ec 100644 --- a/share/tools/web_config/index.html +++ b/share/tools/web_config/index.html @@ -17,38 +17,60 @@ body { #parent { width: 100%; - background-color: black; min-height: 480px; margin-top: 12px; - } #tab_parent { + display: table; width: 100%; - height: 100px; + height: 50px;; } .tab { - border-style: groove; - border-color: #292929; - border-width: 2px; - margin-left: -2px; - margin-right: -2px; + display: table-cell; + border: 1px solid #111; + border-right: none; + padding-bottom: 15px; + padding-top: 15px; font-size: 17pt; - padding-top: 20px; - padding-bottom: 20px; text-align: center; width: 25%; - float: left; background-color: #292929; cursor: pointer; } +#tab_parent :first-child { + border-top-left-radius: 8px; +} + +#tab_parent :last-child { + border-right: 1px solid #111; + border-top-right-radius: 8px; +} + +.tab_first { + border-top-left-radius: 5px; + border-bottom-left-radius: 5px; +} + +.tab_last { + border-top-right-radius: 5px; + border-bottom-right-radius: 5px; +} + .selected_tab { - background-color: inherit; - border-style: none; - margin-left: 0px; - margin-right: -1px; + background-color: black; + border-color: black; +} + +#tab_contents { + padding-top: 35px; + width: 100%; + background-color: black; + border-bottom-left-radius: 8px; + border-bottom-right-radius: 8px; + margin-bottom: 20px; } .footer { @@ -68,7 +90,7 @@ body { text-align: right; min-width: 200px; font-size: 16pt; - padding-bottom: 0px; + padding-bottom: 5px; margin-top: -7px; } @@ -80,6 +102,7 @@ body { padding-bottom: 20px; padding-left: 30px; padding-right: 30px; + border-radius: 5; } #detail_function { @@ -105,6 +128,9 @@ body { border-right: none; background-color: #181818; + border-top-left-radius: 5; + border-bottom-left-radius: 5; + /* Pad one less than .master_element, to accomodate our border. */ padding-top: 5px; padding-bottom: 10px; @@ -134,7 +160,7 @@ body { cursor: pointer; display:inline-block; text-align: center; - border: solid #333 2px; + border: groove #333 2px; padding: 5px; margin-top: 5px; margin-left: auto; @@ -161,6 +187,7 @@ body { .data_table_cell { padding-top: 5px; padding-bottom: 5px; + vertical-align: top; overflow:hidden; border-bottom: #444 dotted 1px; word-wrap: break-word; @@ -171,18 +198,16 @@ body { white-space: nowrap; } -.colorpicker_ground { - position: relative; - bottom: 50px; +.colorpicker_target { margin: 0px; height: 50px; margin-bottom: -50px; } -.colorpicker_ground_tab { +.colorpicker_target_tab { cursor: pointer; - color: #AAA; - border: solid 2px #555; + color: #555; + border: solid 1px #555; padding-top: 5px; padding-bottom: 5px; padding-left: 7px; @@ -192,10 +217,12 @@ body { margin-right: -2px; min-width: 110px; text-align: center; + position: relative; + bottom: 47px; } -.colorpicker_ground_selected { - background-color: #777; +.colorpicker_target_selected { + background-color: #181818; /* same as #detail */ color: white; } @@ -233,11 +260,11 @@ function show_error(msg) { function request_failed(jqXHR, textStatus, errorThrown) { msg = '' if (textStatus == "timeout") { - msg = 'The request timed out. Perhaps the server has exited or is hung.' + msg = 'The request timed out. Perhaps the server has shut down or is hung.' } else if (textStatus == "error") { msg = 'The request received an error.' if (jqXHR.status == 0) - msg = msg + ' Perhaps the server has exited.' + msg = msg + ' Perhaps the server has shut down.' } else if (msg == 'abort') { msg = 'The request aborted.' } else if (msg == 'parsererror') { @@ -448,7 +475,7 @@ function current_master_element_name() { function is_foreground() { /* Returns true if the selected tab is foreground, false if it's background */ - who = $('.colorpicker_ground_selected') + who = $('.colorpicker_target_selected') if (who.length == 0) { show_error('Not sure if we are in foreground or background') return false @@ -517,7 +544,7 @@ function select_function_master_element(elem) { rx = /^[\t ]+/ for (var i=0; i < lines.length; i++) { line = lines[i] - /* Get leading whitespace */ + /* Get leading tabs and spaces */ whitespace_arr = rx.exec(line) if (whitespace_arr) { /* Replace four spaces with two spaces, and tabs with two spaces */ @@ -595,10 +622,10 @@ function picked_modifier(cell) { post_style_to_server() } -function picked_ground(tab) { +function picked_colorpicker_target(tab) { /* The function that gets called when a tab is selected */ - $('.colorpicker_ground_selected').removeClass('colorpicker_ground_selected') - $(tab).addClass('colorpicker_ground_selected') + $('.colorpicker_target_selected').removeClass('colorpicker_target_selected') + $(tab).addClass('colorpicker_target_selected') reflect_style() } @@ -969,30 +996,32 @@ $(document).ready(function() {
colors
-
functions
+
functions
variables
history
-
-
-
-
-
-
Foreground
Background
-
- -
-
-
Underline
+
+
+
+
+
+
+
Text
Background
+
+ +
+
+
Underline
+
+
-
-
- -
- +
+
+ + diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index c0f1aaf7e..c0faddb66 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -258,6 +258,8 @@ while True: ready_read, _, _ = select.select([sys.stdin.fileno(), httpd.fileno()], [], []) if stdin_no in ready_read: print "Shutting down." + # Consume the newline so it doesn't get printed by the caller + sys.stdin.readline() break else: httpd.handle_request()