Make the functions builtin have a bit nicer output

Stop autosuggesting things with newlines
Make webconfig a little nicer
This commit is contained in:
ridiculousfish 2012-03-25 22:41:22 -07:00
parent fa346cec3b
commit a11687fc5c
4 changed files with 98 additions and 54 deletions

View file

@ -1081,7 +1081,7 @@ static int builtin_generic( parser_t &parser, wchar_t **argv )
/** /**
Output a definition of the specified function to the specified 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 ) 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");
} }

View file

@ -1256,6 +1256,7 @@ struct autosuggestion_context_t {
{ {
} }
/* The function run in the background thread to determine an autosuggestion */
int threaded_autosuggest(void) { int threaded_autosuggest(void) {
ASSERT_IS_BACKGROUND_THREAD(); ASSERT_IS_BACKGROUND_THREAD();
@ -1265,6 +1266,11 @@ struct autosuggestion_context_t {
while (searcher.go_backwards()) { while (searcher.go_backwards()) {
history_item_t item = searcher.current_item(); 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; bool item_ok = false;
if (autosuggest_handle_special(item.str(), working_directory, &item_ok)) { if (autosuggest_handle_special(item.str(), working_directory, &item_ok)) {
/* The command autosuggestion was handled specially, so we're done */ /* 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->command_line.empty() )
{ {
if (data->history) { if (data->history) {
//data->history->add(data->command_line);
data->history->add_with_file_detection(data->command_line); data->history->add_with_file_detection(data->command_line);
} }
} }

View file

@ -17,38 +17,60 @@ body {
#parent { #parent {
width: 100%; width: 100%;
background-color: black;
min-height: 480px; min-height: 480px;
margin-top: 12px; margin-top: 12px;
} }
#tab_parent { #tab_parent {
display: table;
width: 100%; width: 100%;
height: 100px; height: 50px;;
} }
.tab { .tab {
border-style: groove; display: table-cell;
border-color: #292929; border: 1px solid #111;
border-width: 2px; border-right: none;
margin-left: -2px; padding-bottom: 15px;
margin-right: -2px; padding-top: 15px;
font-size: 17pt; font-size: 17pt;
padding-top: 20px;
padding-bottom: 20px;
text-align: center; text-align: center;
width: 25%; width: 25%;
float: left;
background-color: #292929; background-color: #292929;
cursor: pointer; 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 { .selected_tab {
background-color: inherit; background-color: black;
border-style: none; border-color: black;
margin-left: 0px; }
margin-right: -1px;
#tab_contents {
padding-top: 35px;
width: 100%;
background-color: black;
border-bottom-left-radius: 8px;
border-bottom-right-radius: 8px;
margin-bottom: 20px;
} }
.footer { .footer {
@ -68,7 +90,7 @@ body {
text-align: right; text-align: right;
min-width: 200px; min-width: 200px;
font-size: 16pt; font-size: 16pt;
padding-bottom: 0px; padding-bottom: 5px;
margin-top: -7px; margin-top: -7px;
} }
@ -80,6 +102,7 @@ body {
padding-bottom: 20px; padding-bottom: 20px;
padding-left: 30px; padding-left: 30px;
padding-right: 30px; padding-right: 30px;
border-radius: 5;
} }
#detail_function { #detail_function {
@ -105,6 +128,9 @@ body {
border-right: none; border-right: none;
background-color: #181818; background-color: #181818;
border-top-left-radius: 5;
border-bottom-left-radius: 5;
/* Pad one less than .master_element, to accomodate our border. */ /* Pad one less than .master_element, to accomodate our border. */
padding-top: 5px; padding-top: 5px;
padding-bottom: 10px; padding-bottom: 10px;
@ -134,7 +160,7 @@ body {
cursor: pointer; cursor: pointer;
display:inline-block; display:inline-block;
text-align: center; text-align: center;
border: solid #333 2px; border: groove #333 2px;
padding: 5px; padding: 5px;
margin-top: 5px; margin-top: 5px;
margin-left: auto; margin-left: auto;
@ -161,6 +187,7 @@ body {
.data_table_cell { .data_table_cell {
padding-top: 5px; padding-top: 5px;
padding-bottom: 5px; padding-bottom: 5px;
vertical-align: top;
overflow:hidden; overflow:hidden;
border-bottom: #444 dotted 1px; border-bottom: #444 dotted 1px;
word-wrap: break-word; word-wrap: break-word;
@ -171,18 +198,16 @@ body {
white-space: nowrap; white-space: nowrap;
} }
.colorpicker_ground { .colorpicker_target {
position: relative;
bottom: 50px;
margin: 0px; margin: 0px;
height: 50px; height: 50px;
margin-bottom: -50px; margin-bottom: -50px;
} }
.colorpicker_ground_tab { .colorpicker_target_tab {
cursor: pointer; cursor: pointer;
color: #AAA; color: #555;
border: solid 2px #555; border: solid 1px #555;
padding-top: 5px; padding-top: 5px;
padding-bottom: 5px; padding-bottom: 5px;
padding-left: 7px; padding-left: 7px;
@ -192,10 +217,12 @@ body {
margin-right: -2px; margin-right: -2px;
min-width: 110px; min-width: 110px;
text-align: center; text-align: center;
position: relative;
bottom: 47px;
} }
.colorpicker_ground_selected { .colorpicker_target_selected {
background-color: #777; background-color: #181818; /* same as #detail */
color: white; color: white;
} }
@ -233,11 +260,11 @@ function show_error(msg) {
function request_failed(jqXHR, textStatus, errorThrown) { function request_failed(jqXHR, textStatus, errorThrown) {
msg = '' msg = ''
if (textStatus == "timeout") { 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") { } else if (textStatus == "error") {
msg = 'The request received an error.' msg = 'The request received an error.'
if (jqXHR.status == 0) if (jqXHR.status == 0)
msg = msg + ' Perhaps the server has exited.' msg = msg + ' Perhaps the server has shut down.'
} else if (msg == 'abort') { } else if (msg == 'abort') {
msg = 'The request aborted.' msg = 'The request aborted.'
} else if (msg == 'parsererror') { } else if (msg == 'parsererror') {
@ -448,7 +475,7 @@ function current_master_element_name() {
function is_foreground() { function is_foreground() {
/* Returns true if the selected tab is foreground, false if it's background */ /* 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) { if (who.length == 0) {
show_error('Not sure if we are in foreground or background') show_error('Not sure if we are in foreground or background')
return false return false
@ -517,7 +544,7 @@ function select_function_master_element(elem) {
rx = /^[\t ]+/ rx = /^[\t ]+/
for (var i=0; i < lines.length; i++) { for (var i=0; i < lines.length; i++) {
line = lines[i] line = lines[i]
/* Get leading whitespace */ /* Get leading tabs and spaces */
whitespace_arr = rx.exec(line) whitespace_arr = rx.exec(line)
if (whitespace_arr) { if (whitespace_arr) {
/* Replace four spaces with two spaces, and tabs with two spaces */ /* Replace four spaces with two spaces, and tabs with two spaces */
@ -595,10 +622,10 @@ function picked_modifier(cell) {
post_style_to_server() post_style_to_server()
} }
function picked_ground(tab) { function picked_colorpicker_target(tab) {
/* The function that gets called when a tab is selected */ /* The function that gets called when a tab is selected */
$('.colorpicker_ground_selected').removeClass('colorpicker_ground_selected') $('.colorpicker_target_selected').removeClass('colorpicker_target_selected')
$(tab).addClass('colorpicker_ground_selected') $(tab).addClass('colorpicker_target_selected')
reflect_style() reflect_style()
} }
@ -969,30 +996,32 @@ $(document).ready(function() {
<div id="parent"> <div id="parent">
<div id="tab_parent"> <div id="tab_parent">
<div class="tab selected_tab" id="tab_colors" onClick="switch_tab('tab_colors')">colors</div> <div class="tab selected_tab" id="tab_colors" onClick="switch_tab('tab_colors')">colors</div>
<div class="tab" id="tab_functions" onClick="switch_tab('tab_functions')">functions</div> <div class="tab" id="tab_functions" onClick="switch_tab('tab_functions')">functions</div>
<div class="tab" id="tab_variables" onClick="switch_tab('tab_variables')">variables</div> <div class="tab" id="tab_variables" onClick="switch_tab('tab_variables')">variables</div>
<div class="tab" id="tab_history" onClick="switch_tab('tab_history')">history</div> <div class="tab" id="tab_history" onClick="switch_tab('tab_history')">history</div>
</div> </div>
<div id="master_detail_table"> <div id="tab_contents">
<div id="master"></div> <div id="master_detail_table">
<div id="detail"> <div id="master"></div>
<div id="detail_colorpicker"> <div id="detail">
<div class="colorpicker_ground"> <div id="detail_colorpicker">
<div class="colorpicker_ground_tab colorpicker_ground_selected" id="foreground" onClick="picked_ground(this)">Foreground</div><div class="colorpicker_ground_tab" id="background" onClick="picked_ground(this)">Background</div> <div class="colorpicker_target">
</div> <div class="colorpicker_target_tab tab_first colorpicker_target_selected" id="foreground" onClick="picked_colorpicker_target(this)">Text</div><div class="colorpicker_target_tab tab_last" id="background" onClick="picked_colorpicker_target(this)">Background</div>
<table id="colorpicker_term256"> </div>
</table> <table id="colorpicker_term256">
<div class="colorpicker_modifiers"> </table>
<div class="colorpicker_modifier_cell" id="modifier_underline" style="text-decoration: underline" onClick='picked_modifier(this)'>Underline</div> <div class="colorpicker_modifiers">
<div class="colorpicker_modifier_cell" id="modifier_underline" style="text-decoration: underline" onClick='picked_modifier(this)'>Underline</div>
</div>
</div> </div>
<div id="detail_function"></div>
</div> </div>
<div id="detail_function"></div>
</div> </div>
</div> <table id="data_table">
<table id="data_table"> <table>
<table> <div class="footer">
<div class="footer"> </div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -258,6 +258,8 @@ while True:
ready_read, _, _ = select.select([sys.stdin.fileno(), httpd.fileno()], [], []) ready_read, _, _ = select.select([sys.stdin.fileno(), httpd.fileno()], [], [])
if stdin_no in ready_read: if stdin_no in ready_read:
print "Shutting down." print "Shutting down."
# Consume the newline so it doesn't get printed by the caller
sys.stdin.readline()
break break
else: else:
httpd.handle_request() httpd.handle_request()