## ## colorprompt.g Frank Lübeck ## ## A demo for customizing the GAP prompt. ## ## To switch off the coloring of prompt and input call ## ColorPrompt(false); ## To switch off use of colors completely say ## ANSI_COLORS := false; ## Revision.colorprompt_g := "$Id: colorprompt.g,v 1.3 2004/05/13 11:29:28 gap Exp $"; ANSI_COLORS := true; STDOUT := OutputTextUser();; PrintPromptHook := CPROMPT;; EndLineHook := function() end;; ColorPrompt := function(b) if b=false then Unbind(PrintPromptHook); Unbind(EndLineHook); return; fi; # my colored interface # we stored this above to avoid overwriting last system error with # function call ### STDOUT := OutputTextUser(); # print the prompt PrintPromptHook := function() local cp; cp := CPROMPT(); if cp = "gap> " then cp := "gap> "; fi; # different color for brk...> prompts if Length(cp)>0 and cp[1] = 'b' then WriteAll(STDOUT, "\033[1m\033[31m"); else WriteAll(STDOUT, "\033[1m\033[34m"); fi; # use this instead of Print such that the column counter for the # command line editor is correct PRINT_CPROMPT(cp); # another color for input WriteAll(STDOUT, "\033[0m\033[31m"); end; # reset attributes before going to the next line EndLineHook := function() WriteAll(STDOUT, "\033[0m"); end; end; # use colored prompt as default, since this file is only read explicitly ColorPrompt(true);