Skip to content

Commit

Permalink
Various client program fixes.
Browse files Browse the repository at this point in the history
Among them:
 - move loading of ~/.juliarc[.j] into client.j
 - always flush the print buffer regardless of having color
 - disable color for -e and -E (this is a bit of a hack)
 - allow color for any TERM variable starting with xterm
  • Loading branch information
StefanKarpinski committed Jan 26, 2012
1 parent 92fce17 commit c61a4d0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
9 changes: 4 additions & 5 deletions j/client.j
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,17 @@ function _start()
global const VARIABLES = {}

# Load customized startup
try
load(strcat(getcwd(),"/startup.j"))
catch
end
try load(strcat(getcwd(),"/startup.j")) end
try load(strcat(ENV["HOME"],"/.juliarc")) end

(quiet,repl) = process_options(ARGS)

if repl
if !quiet
_jl_banner()
end
run_repl()
else
ccall(:jl_disable_color, Void, ())
end
catch e
show(e)
Expand Down
3 changes: 0 additions & 3 deletions j/start_image.j
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,3 @@ _jl_libfftw = dlopen("libfftw3")
_jl_libfftwf = dlopen("libfftw3f")
_jl_libsuitesparse = dlopen("libsuitesparse");
_jl_libsuitesparse_wrapper = dlopen("libsuitesparse_wrapper");

# load personal startup file
try load(strcat(ENV["HOME"],"/.juliarc")) end
11 changes: 6 additions & 5 deletions ui/repl.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ int tab_width = 2;
int prompt_length = 0;
int have_color = 1;

void jl_disable_color() { have_color = 0; }

static const char *usage = "julia [options] [program] [args...]\n";
static const char *opts =
" -v --version Display version information\n"
" -q --quiet Quiet startup without banner\n"
" -H --home=<dir> Load files relative to <dir>\n"
" -T --tab=<size> Set REPL tab width to <size>\n\n"

" -e --eval=<expr> Evaluate <expr> and don't print\n"
" -E --print=<expr> Evaluate and print <expr>\n"
" -e --eval=<expr> Evaluate <expr>\n"
" -E --print=<expr> Evaluate and show <expr>\n"
" -P --post-boot=<expr> Evaluate <expr> right after boot\n"
" -L --load=file Load <file> right after boot\n"
" -b --bare Bare: don't load default startup files\n"
Expand Down Expand Up @@ -138,8 +140,7 @@ static int detect_color(void)
if (tput == 0) return 1;
if (tput == 1) return 0;
char *term = getenv("TERM");
if (term == NULL) return 0;
return (!strcmp(term,"xterm") || !strcmp(term,"xterm-color"));
return term && !strncmp(term,"xterm",5);
#endif
}

Expand Down Expand Up @@ -176,8 +177,8 @@ static void exit_repl(int code)

if (have_color) {
ios_printf(ios_stdout, jl_color_normal);
ios_flush(ios_stdout);
}
ios_flush(ios_stdout);
#ifdef JL_GF_PROFILE
print_profile();
#endif
Expand Down
1 change: 1 addition & 0 deletions ui/repl.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ extern void handle_input(jl_value_t *ast, int end, int show_value);
extern int ends_with_semicolon(const char *input);
extern char *ios_readline(ios_t *s);
DLLEXPORT extern void repl_callback_enable();
DLLEXPORT extern void jl_disable_color();
extern void repl_callback_disable();
extern void repl_stdin_callback();
extern void repl_print_prompt();
Expand Down

0 comments on commit c61a4d0

Please sign in to comment.