Remove set_color from Makefile. Fix issue where builtin_set_color would mix output modes up

This commit is contained in:
ridiculousfish 2013-02-14 16:46:54 -08:00
parent 8d95d0834d
commit 12332328c1
4 changed files with 33 additions and 144 deletions

View file

@ -69,7 +69,6 @@ LDFLAGS_FISH_INDENT = ${LDFLAGS} @LIBS_FISH_INDENT@
LDFLAGS_FISH_PAGER = ${LDFLAGS} @LIBS_FISH_PAGER@
LDFLAGS_FISHD = ${LDFLAGS} @LIBS_FISHD@
LDFLAGS_MIMEDB = ${LDFLAGS} @LIBS_MIMEDB@
LDFLAGS_SET_COLOR = ${LDFLAGS} @LIBS_SET_COLOR@
#
# Set to 1 if we have gettext
@ -106,7 +105,8 @@ parser_keywords.o wutil.o tokenizer.o
#
BUILTIN_FILES := builtin_set.cpp builtin_commandline.cpp \
builtin_ulimit.cpp builtin_complete.cpp builtin_jobs.cpp
builtin_ulimit.cpp builtin_complete.cpp builtin_jobs.cpp \
bulitin_set_color.cpp
#
@ -199,7 +199,7 @@ DOC_SRC_DIR_FILES := $(HDR_FILES_SRC) $(HELP_SRC)
MAIN_DIR_FILES_UNSORTED := Doxyfile Doxyfile.user Doxyfile.help \
Makefile.in configure configure.ac config.h.in install-sh \
set_color.cpp key_reader.cpp $(MIME_OBJS:.o=.h) \
key_reader.cpp $(MIME_OBJS:.o=.h) \
$(MIME_OBJS:.o=.cpp) $(FISH_OBJS:.o=.h) $(BUILTIN_FILES) \
$(COMMON_FILES) $(COMMON_FILES:.cpp=.h) $(FISH_OBJS:.o=.cpp) \
fish.spec.in INSTALL README user_doc.head.html xsel-0.9.6.tar \
@ -241,7 +241,7 @@ FUNCTIONS_DIR_FILES := $(wildcard share/functions/*.fish)
# Programs to install
#
SIMPLE_PROGRAMS := fish set_color mimedb fish_pager fishd fish_indent
SIMPLE_PROGRAMS := fish mimedb fish_pager fishd fish_indent
PROGRAMS := $(SIMPLE_PROGRAMS) @XSEL_BIN@
@ -755,14 +755,6 @@ mimedb: $(MIME_OBJS)
$(CXX) $(MIME_OBJS) $(LDFLAGS_MIMEDB) -o $@
#
# Build the set_color program
#
set_color: set_color.o print_help.o common.o color.o wutil.o
$(CXX) set_color.o print_help.o common.o wutil.o color.o $(LDFLAGS_SET_COLOR) -o $@
#
# Build the fish_indent program.
#
@ -992,8 +984,6 @@ sanity.o: config.h signal.h fallback.h util.h common.h sanity.h proc.h io.h
sanity.o: history.h wutil.h reader.h complete.h kill.h
screen.o: config.h fallback.h signal.h common.h util.h wutil.h output.h
screen.o: screen.h color.h highlight.h env.h
set_color.o: config.h fallback.h signal.h print_help.h color.h common.h
set_color.o: util.h
signal.o: config.h signal.h common.h util.h fallback.h wutil.h event.h
signal.o: reader.h io.h complete.h proc.h
tokenizer.o: config.h fallback.h signal.h util.h wutil.h common.h tokenizer.h

View file

@ -45,13 +45,21 @@ static void print_colors(void)
}
}
/* function we set as the output writer */
static std::string builtin_set_color_output;
static int set_color_builtin_outputter(char c)
{
ASSERT_IS_MAIN_THREAD();
builtin_set_color_output.push_back(c);
return 0;
}
/**
set_color builtin
*/
static int builtin_set_color(parser_t &parser, wchar_t **argv)
{
/** Variables used for parsing the argument list */
const struct woption long_options[] =
{
{ L"background", required_argument, 0, 'b'},
@ -150,16 +158,23 @@ static int builtin_set_color(parser_t &parser, wchar_t **argv)
return STATUS_BUILTIN_ERROR;
}
/* Save old output function so we can restore it */
int (* const saved_writer_func)(char) = output_get_writer();
/* Set our output function, which writes to a std::string */
builtin_set_color_output.clear();
output_set_writer(set_color_builtin_outputter);
if (bold)
{
if (enter_bold_mode)
putp(enter_bold_mode);
writembs(tparm(enter_bold_mode));
}
if (underline)
{
if (enter_underline_mode)
putp(enter_underline_mode);
writembs(enter_underline_mode);
}
if (bgcolor != NULL)
@ -167,7 +182,7 @@ static int builtin_set_color(parser_t &parser, wchar_t **argv)
if (bg.is_normal())
{
write_background_color(0);
putp(tparm(exit_attribute_mode));
writembs(tparm(exit_attribute_mode));
}
}
@ -176,7 +191,7 @@ static int builtin_set_color(parser_t &parser, wchar_t **argv)
if (fg.is_normal())
{
write_foreground_color(0);
putp(tparm(exit_attribute_mode));
writembs(tparm(exit_attribute_mode));
}
else
{
@ -191,5 +206,14 @@ static int builtin_set_color(parser_t &parser, wchar_t **argv)
write_background_color(index_for_color(bg));
}
}
/* Restore saved writer function */
output_set_writer(saved_writer_func);
/* Output the collected string */
std::string local_output;
std::swap(builtin_set_color_output, local_output);
stdout_buffer.append(str2wcstring(local_output));
return STATUS_BUILTIN_OK;
}

View file

@ -30,7 +30,6 @@ AC_SUBST(LIBS_FISH_INDENT)
AC_SUBST(LIBS_FISH_PAGER)
AC_SUBST(LIBS_FISHD)
AC_SUBST(LIBS_MIMEDB)
AC_SUBST(LIBS_SET_COLOR)
AC_SUBST(localedir)
AC_SUBST(optbindirs)
AC_SUBST(prefix)
@ -527,18 +526,6 @@ LIBS_MIMEDB=$LIBS
LIBS=$LIBS_COMMON
#
# Check for libraries needed by set_color
#
LIBS_COMMON=$LIBS
LIBS="$LIBS_SHARED"
if test x$local_gettext != xno; then
AC_SEARCH_LIBS( gettext, intl,,)
fi
LIBS_SET_COLOR=$LIBS
LIBS=$LIBS_COMMON
#
# Check presense of various header files
#

View file

@ -20,7 +20,6 @@
D07D265915E33B86009E43F6 /* PBXTargetDependency */,
D07D265B15E33B86009E43F6 /* PBXTargetDependency */,
D07D265D15E33B86009E43F6 /* PBXTargetDependency */,
D07D265F15E33B86009E43F6 /* PBXTargetDependency */,
D0A56500168D257900AF6161 /* PBXTargetDependency */,
);
name = install_tree;
@ -52,7 +51,6 @@
D0F01A1515AA362E0034B3B1 /* PBXTargetDependency */,
D0F01A1915AA36310034B3B1 /* PBXTargetDependency */,
D0F01A1715AA36300034B3B1 /* PBXTargetDependency */,
D0F01A1B15AA36330034B3B1 /* PBXTargetDependency */,
D0A564EF168D09C000AF6161 /* PBXTargetDependency */,
);
name = base;
@ -144,18 +142,10 @@
D0D1CD7515B7458B00F03988 /* common.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0A0853613B3ACEE0099B651 /* common.cpp */; };
D0D2694915983772005D9B9C /* function.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0A0854413B3ACEE0099B651 /* function.cpp */; };
D0D2694A15983779005D9B9C /* builtin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0A0853513B3ACEE0099B651 /* builtin.cpp */; };
D0F019E215A969B40034B3B1 /* set_color.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0A0855B13B3ACEE0099B651 /* set_color.cpp */; };
D0F019E315A969BA0034B3B1 /* print_help.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0A0855613B3ACEE0099B651 /* print_help.cpp */; };
D0F019E415A969C00034B3B1 /* common.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0A0853613B3ACEE0099B651 /* common.cpp */; };
D0F019E515A969C30034B3B1 /* color.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0B6B0FE14E88BA400AD6C10 /* color.cpp */; };
D0F019E615A969C80034B3B1 /* wutil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0A0856113B3ACEE0099B651 /* wutil.cpp */; };
D0F019E915A96A0A0034B3B1 /* libncurses.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D0D02A8C15983CFA008E62BD /* libncurses.dylib */; };
D0F019EA15A96A0C0034B3B1 /* libiconv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D0D02A8A15983CDF008E62BD /* libiconv.dylib */; };
D0F019F115A977140034B3B1 /* fish in CopyFiles */ = {isa = PBXBuildFile; fileRef = D0D2693C159835CA005D9B9C /* fish */; };
D0F019F215A977270034B3B1 /* fishd in CopyFiles */ = {isa = PBXBuildFile; fileRef = D0D02ABC15985EF9008E62BD /* fishd */; };
D0F019F315A977290034B3B1 /* fish_indent in CopyFiles */ = {isa = PBXBuildFile; fileRef = D0D02AD01598642A008E62BD /* fish_indent */; };
D0F019F415A9772C0034B3B1 /* fish_pager in CopyFiles */ = {isa = PBXBuildFile; fileRef = D0D02AE415986537008E62BD /* fish_pager */; };
D0F019F615A977360034B3B1 /* set_color in CopyFiles */ = {isa = PBXBuildFile; fileRef = D0F019DC15A969970034B3B1 /* set_color */; };
D0F019F815A977AB0034B3B1 /* config.fish in CopyFiles */ = {isa = PBXBuildFile; fileRef = D0CBD580159EE48F0024809C /* config.fish */; };
D0F019FD15A977CA0034B3B1 /* config.fish in CopyFiles */ = {isa = PBXBuildFile; fileRef = D0C4FD9415A7D7EE00212EF1 /* config.fish */; };
D0F01A0315A978910034B3B1 /* osx_fish_launcher.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D02AFA159871B2008E62BD /* osx_fish_launcher.m */; };
@ -198,13 +188,6 @@
remoteGlobalIDString = D0D02ACF1598642A008E62BD;
remoteInfo = fish_indent;
};
D07D266015E33B86009E43F6 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = D0A084F213B3AC130099B651 /* Project object */;
proxyType = 1;
remoteGlobalIDString = D0F019DB15A969970034B3B1;
remoteInfo = set_color;
};
D0A564EE168D09C000AF6161 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = D0A084F213B3AC130099B651 /* Project object */;
@ -247,13 +230,6 @@
remoteGlobalIDString = D0D02AE315986537008E62BD;
remoteInfo = fish_pager;
};
D0F01A1A15AA36330034B3B1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = D0A084F213B3AC130099B651 /* Project object */;
proxyType = 1;
remoteGlobalIDString = D0F019DB15A969970034B3B1;
remoteInfo = set_color;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
@ -326,7 +302,6 @@
D0F019F215A977270034B3B1 /* fishd in CopyFiles */,
D0F019F315A977290034B3B1 /* fish_indent in CopyFiles */,
D0F019F415A9772C0034B3B1 /* fish_pager in CopyFiles */,
D0F019F615A977360034B3B1 /* set_color in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -482,7 +457,6 @@
D0D02AE415986537008E62BD /* fish_pager */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = fish_pager; sourceTree = BUILT_PRODUCTS_DIR; };
D0D02AFA159871B2008E62BD /* osx_fish_launcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = osx_fish_launcher.m; path = osx/osx_fish_launcher.m; sourceTree = "<group>"; };
D0D2693C159835CA005D9B9C /* fish */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = fish; sourceTree = BUILT_PRODUCTS_DIR; };
D0F019DC15A969970034B3B1 /* set_color */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = set_color; sourceTree = BUILT_PRODUCTS_DIR; };
D0F3373A1506DE3C00ECEFC0 /* builtin_test.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = builtin_test.cpp; sourceTree = "<group>"; };
D0F5E28415A7A32D00315DFF /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -524,15 +498,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
D0F019D915A969970034B3B1 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D0F019E915A96A0A0034B3B1 /* libncurses.dylib in Frameworks */,
D0F019EA15A96A0C0034B3B1 /* libiconv.dylib in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
D0F01A0415A9789C0034B3B1 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@ -733,7 +698,6 @@
D0D02ABC15985EF9008E62BD /* fishd */,
D0D02AD01598642A008E62BD /* fish_indent */,
D0D02AE415986537008E62BD /* fish_pager */,
D0F019DC15A969970034B3B1 /* set_color */,
);
name = Products;
sourceTree = "<group>";
@ -848,22 +812,6 @@
productReference = D0D2693C159835CA005D9B9C /* fish */;
productType = "com.apple.product-type.tool";
};
D0F019DB15A969970034B3B1 /* set_color */ = {
isa = PBXNativeTarget;
buildConfigurationList = D0F019DF15A969970034B3B1 /* Build configuration list for PBXNativeTarget "set_color" */;
buildPhases = (
D0F019D815A969970034B3B1 /* Sources */,
D0F019D915A969970034B3B1 /* Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = set_color;
productName = set_color;
productReference = D0F019DC15A969970034B3B1 /* set_color */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
@ -891,7 +839,6 @@
D0D02ABB15985EF9008E62BD /* fishd */,
D0D02ACF1598642A008E62BD /* fish_indent */,
D0D02AE315986537008E62BD /* fish_pager */,
D0F019DB15A969970034B3B1 /* set_color */,
D0A564E6168CFDD800AF6161 /* man_pages */,
D0A084F713B3AC130099B651 /* Makefile */,
);
@ -1158,18 +1105,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
D0F019D815A969970034B3B1 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D0F019E515A969C30034B3B1 /* color.cpp in Sources */,
D0F019E215A969B40034B3B1 /* set_color.cpp in Sources */,
D0F019E315A969BA0034B3B1 /* print_help.cpp in Sources */,
D0F019E415A969C00034B3B1 /* common.cpp in Sources */,
D0F019E615A969C80034B3B1 /* wutil.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
D0F01A0215A9788B0034B3B1 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@ -1206,11 +1141,6 @@
target = D0D02ACF1598642A008E62BD /* fish_indent */;
targetProxy = D07D265E15E33B86009E43F6 /* PBXContainerItemProxy */;
};
D07D265F15E33B86009E43F6 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = D0F019DB15A969970034B3B1 /* set_color */;
targetProxy = D07D266015E33B86009E43F6 /* PBXContainerItemProxy */;
};
D0A564EF168D09C000AF6161 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = D0A564E6168CFDD800AF6161 /* man_pages */;
@ -1241,11 +1171,6 @@
target = D0D02AE315986537008E62BD /* fish_pager */;
targetProxy = D0F01A1815AA36310034B3B1 /* PBXContainerItemProxy */;
};
D0F01A1B15AA36330034B3B1 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = D0F019DB15A969970034B3B1 /* set_color */;
targetProxy = D0F01A1A15AA36330034B3B1 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
@ -1504,34 +1429,6 @@
};
name = Release;
};
D0F019E015A969970034B3B1 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_UNINITIALIZED_AUTOS = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
D0F019E115A969970034B3B1 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
D0F019EE15A976F30034B3B1 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
@ -1636,15 +1533,6 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
D0F019DF15A969970034B3B1 /* Build configuration list for PBXNativeTarget "set_color" */ = {
isa = XCConfigurationList;
buildConfigurations = (
D0F019E015A969970034B3B1 /* Debug */,
D0F019E115A969970034B3B1 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
D0F019ED15A976F30034B3B1 /* Build configuration list for PBXAggregateTarget "base" */ = {
isa = XCConfigurationList;
buildConfigurations = (