Programming :: Printf() In C Being Able To Specify Foreground / Background Colors?
Nov 21, 2010
I got curious during the construction of my program to search for blocks of text that contain certain words, and wanted to print out blocks of text with the words I was searching for, initially, in ALL CAPS and seperated by tabs for easy identification. That got boring, though, so I thought, "Can printf do colors, too?" Yes it can.... Who knew?
[Code],,,
View 8 Replies
ADVERTISEMENT
Aug 19, 2009
I've read about this. Everyone says to use ~/.Xresources or ~/.Xdefaults, and it doesn't work for me. It doesn't do anything at all, in fact. I'm trying to use this:
Code:
XTerm*background: black
XTerm*foreground: white
In the ~/.X* files, it won't work. I read that another way of doing it is using
Code:
xrdb -merge .x_settings_file
This will work for me. It's the only thing I can get to work. But when I restart, it will have to be done again. I'm using Slackware 12.2.
View 1 Replies
View Related
Dec 30, 2009
I want to set my top gnome-panel's background opacity to about 80, while having foreground opacity (fonts and images) set to 100.
View 1 Replies
View Related
May 17, 2010
I am trying to solve one problem: When i run my process in background it hogs around 96% of CPU. But when ran in foreground, CPU utilization is almost zero. Is there any difference b/n a background and a foreground process wrto CPU utilization?
View 8 Replies
View Related
Mar 5, 2010
is it possible in bash to run one command in background and after it's done show output with less? While background process is running I should be able enter another commands.What I have is this (sleep is only for simulation):
Code:
{({ ( tree / > tree.txt && sleep 2) & } && wait && less tree.txt) &} && wait fg &
Problem is that I don't know and I can't find how to move it to the foreground after completion.
View 14 Replies
View Related
May 18, 2011
q)how can i bring the backgroud process to foreground i tried like below1]hp-linux@hp-linux-desktop:/usr/share$ top
top - 11:28:24 up 1:57, 2 users, load average: 0.55, 0.65, 0.62
Tasks: 158 total, 3 running, 155 sleeping, 0 stopped, 0 zombie
Cpu(s): 6.1%us, 2.9%sy, 0.7%ni, 87.1%id, 3.0%wa, 0.2%hi, 0.1%si, 0.0%st
[code]...
View 4 Replies
View Related
Sep 28, 2010
I've just entered the world of linux and the first thing that I find is the terminal. Can anyone teach me how to change the background and text colors in terminal
View 2 Replies
View Related
Jul 23, 2010
Alright, this has been driving me bonkers for months now and I can't find the answer anywhere. I like the custom theme options with standard gnome just fine, plenty of adjustments that can be made, with only one adjustment missing which would create perfection (at least in my opinion).
How on earth is it possible to change the backgrounds of the "mini-panels" which are always grey by default? No matter which Theme I choose and customize, I can never get the background color of the time/date applet, monitors, evolution, garbage can, and so on to change. I'd like to make all of the backgrounds transparent, not just the main panels that contain the other stuff. Is this even possible, and if so, how?I'm assuming since all of those apps have the same default color that an adjustment "wherever" would then change those default colors on all of the applets (hopefully).
View 9 Replies
View Related
Nov 29, 2010
I have version 10.10 installed on both a desktop and a laptop. They are both close in how I setup the themes etc. However on the desktop I notice that I am missing some of the background colors on windows and in some websites. It seems to be anything using a blue/gray color. And it is White. It is noticeable on my Firefox on the laptop the borders around everything is gray, but on the desktop these are white. This seems to be not limited to the browser, as I investigated it is on all apps. I have googled this but cannot find a similar situation. I am also new to Ubuntu/Linux, which adds to my dilemma.
View 2 Replies
View Related
Feb 18, 2010
I'm using xterm/screen/vim, and set them up to 256 color mode. Everything went well, except when background color for the theme I choose is not black.
Here's the theme I use in this example:[URL].. Here's the situation: as long as I only use vim, the background is well rendered, meaning everything is grey in vim background. But when I try this with screen, the background is back to black, and only the text get some kind of highlight with the background color.Here are the magical lines I added to screenrc:
Code:
term screen-256color
attrcolor b ".I"
# Tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm 'Co#256:AB=E[48;5;%dm:AF=E[38;5;%dm'
# Erase background with current bg color. Not needed if TERM=screen-256color
defbce "on"
Colors are well rendered in 256 color, I only have a problem with this background. Anyone knows how to 'fix' this?
View 1 Replies
View Related
May 10, 2011
Id like to share with you a strange behavior I�ve been seen with the printf C language function running in Fedora.The code opens a file as showed:descString = fopen( strcat( stringName, txt), a+);There are also some printf functions in the code.However, instead of the printf functions to print their content at the screen, theyve been printing them in the file with the descString file descriptor.Have you ever seen something like that?To print something to the file I use the fprintf function. I didn't make a mistake to confuse printf with fprintf. I'm sure.
View 2 Replies
View Related
Feb 2, 2010
For eg: $NUMBEROFPASSES=6.19 to round up I use NUMBEROFPASSES=$(printf %.0f $NUMBEROFPASSES) What I need to do is round up from eg: 6.10 to be 7 and if lower than 6.10 round down to 6
View 5 Replies
View Related
Jun 7, 2010
misunderstood structure definition at the beginning
View 3 Replies
View Related
Sep 20, 2010
I am trying to port some "C" code from Solaris to Linux. I have a Dell PowerEdge R610 with an Intel Xeon E5504 quad core processor running Red Hat Linux Enterprise 5.3. I am compiling in 64 bit mode. I have managed to get the code compiled and linked, but when I attempt to execute it, I get a core dump in one of the C library calls (like strcpy or printf.)
I have a static library that contains our own code that makes the call to the C library. If I move the library method into the source file with the main method and rename it to be certain that I am executing my method instead of the method in our library, the call succeeds. Eventually another static library call is made that results in a core dump in the shared object. I compile my library code into a static library with gcc as:
[Code]....
View 3 Replies
View Related
Apr 16, 2010
I have many processes running that printf local debug. (they will log to file later!) I start them by
Code:
( sleep 20000000 | fp ) & else they get killed/stop by themselves. So now its running in the background, I want to bring it to the front to see the printfs.
[Code]....
View 14 Replies
View Related
May 19, 2010
I recently installed Ubuntu 10.04 Netbook Remix on my Gateway LT3103u. I noticed shortly into using it that it has a graphics bug every so often. Especially when I change the background image. Everything will change to a warped mix of colors and pixels. Everything is affected. My mouse, the bar at the top of the screen, text and all. My netbook runs on an AMD Athlon 64-bit processor with ATI Radeon X1270 HyperMemory up to 256MB graphics.
So far I have tried reinstalling, and even the 64bit desktop edition which had the same problem. Ive noticed that it freaks out when i scroll too quick, when changing background images, and on certain websites. Then other times its completely random. When it happens it looks similar to these: [URL]
View 4 Replies
View Related
Mar 6, 2010
I was recently using Xubuntu for awhile, and I really enjoyed the default color scheme it had, I was wondering if anyone had the colors in HTML that Xubuntu uses?
I'm looking for the "Background & Text" colors for Windows, Input Boxes, Selected Items, & Tooltips and then I was just going to input them under "Customize Themes"
View 1 Replies
View Related
Jan 15, 2011
I am intended to simply make printf give "001 002 003 004 006.... 150" but with the single command line of SH (dash) ... not easy ...
Code:
tucholsky:~$ seq 1 1 150 | sed 's/([0-9]+).*/1/g' | tr '
' ' '
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
[code]...
For the geeks, which distro/version is it, based on the code above
View 6 Replies
View Related
Apr 27, 2010
I'm trying to understand how to use colors in Xlib programming. What I think I understand so far is that modern displays use 24 or 32-bit TrueColor. And TrueColor uses three colormaps, one for each primary color, and a single pixel value is composed of three indices.
Now the part i'm confused about is how to get my programs to use a 32-bit TrueColor visual. I thought I could inheret the visual from the root window to get color but it seems no matter what pixel value I use it's either black or white.
I guess my question is, how can I setup my programs so that I can specify a pixel value that is a combination of RGB values to get the color I want?
I come from windows where I simply used RGB(r,g,b) macro to specify colors and never had to worry about depth and colormaps and visuals, so I'm a bit overwhelmed by all of these concepts.
View 1 Replies
View Related
Oct 28, 2009
using the code
Code:
void setplane(unsigned char mask){
inportb(0x3DA); //Reset the VGA flip/flop
unsigned char c=inportb(0x3C0); /*the VGA does not like you not saving values*/
[code]....
does not work, for example if setplane(1); will change all pixels plotted to blue - not just the newest. and here is how i plot pixels:
Code:
void ppixel(unsigned x, unsigned y, unsigned char color){
setplane(color);
((char far *)0xA0000000L)[(y*(640/8))+(x/8)]=((1<<7)>>(x%8));
}
View 2 Replies
View Related
Mar 24, 2010
I am trying to use bash 'printf' to format an environment variable.Doing this I get on the screen just the format I need (underscores mean blank spaces):prompt> printf "%10s" "1.23"________1.23Unfortunately, when this is assigned to a variable, the format disappears:prompt> X=`printf "%10s" "1.23"`prompt> echo $X1.23Does anyone know what can be done in this case to get a proper format?Why does not 'printf' respect the left blank spaces when assigning values to a variable?
View 3 Replies
View Related
Jul 3, 2009
I have a xterm which can have 256 colors. How can I configure the prompt colors and ls output colors to take advantages of the 256 color values?
View 4 Replies
View Related
Dec 16, 2010
Some context: I'm calling some functions from within a C program and want to measure how long they take to execute. I've done this successfully, calling printf to print the results to the screen. This is reasonably fast. Ideally I'd like these to be dumped to a file, but fprintf presumably has some overhead since it writes to disk? Unless the data is buffered by the kernel and flushed later? What kind of delay can I expect before fprintf returns?
If I redirect the stdout to a file when I instantiate the binary as a process, will calls to printf also experience any overhead from redirection to a file? My aim here is to capture all data in a file, with the minimal amount of coding and effort, but with minimal impact in terms of time overheads for printf calls.
View 10 Replies
View Related
Mar 26, 2010
I wrote a spinner in Perl and when I did a spinner in shell I could just run the subroutine in the background.
[code]...
In Perl, how do you run a function in a background and get the PID for that? I know PID in Perl is $$
View 2 Replies
View Related
May 22, 2010
I've got a C program that I've added some 'printf' statements to monitor a couple of variables. When I run this program manually or from a script, the output is displayed on screen. However, I need to change various variables in the 'test.c' file, run 'make clean' and 'make' a few hundred thousand times. I'm using a script to read the variables in and then using sed to do in-place edits of the file. Unfortunately, with this amount of iteration, it is getting rather tired!
Anyway, I've created a script that is working as long I respond to prompts. I've tried the following to no avail: Code: /path/to/script > /tmp/output /path/to/script > /tmp/output 2>&1 /path/to/script | tee (no output even after adding the -a option) In my C program, I have the following 'printf' statement: Code: printf ("variable1: $s variable2: $s",var1,var2); What am I missing? I've worked with redirection before and it's always worked out fine, but this one plain stumps!
View 2 Replies
View Related
Jun 15, 2010
I am having trouble keeping the name together and the phone number together, I think due to the white space. I have tried "" and '' it doesn't seem to matter. So it may be my syntax? and does it matter how long the first and last names are.
me$ echo 'fstname lstname' '123 123-1234' | ./myscript
#myscript
read a b
printf "%-15s %20s
" $a $b >> my_phone_numbers
OUTPUT
fstnamelstname
123123-1234
insted of
fstname lstname
123 123-1234
I know its not an elegant script but I am still learning how some commands work.
View 2 Replies
View Related
Mar 10, 2010
I think my title pretty much explains it. I am writing a script and I want to start a program in the background, and when that program finishes I want to check the return value to make sure there was no error.For example normal I would do something like this:
#!/bin/sh
program
if [ ! $? -eq 0 ]; then
echo "There was an error"
exit 1
fi
Now I want to do something like this:
#!/bin/sh
PRTN=`program1 &`
program2
if [ ! $? -eq 0 ]; then
[code]....
In this case if program2 finishes before program1, I don't think the return value from program1 $PRTN would be valid at the time it is checked.
View 3 Replies
View Related
Apr 6, 2010
I have some ideas about writing a small game in terminal ( just for fun ) using ncurses library. I want to use some kind of menus (in Midnight Commander's style), but there are some problems with rendering windows, that I don't understand. I create a window with newwin(), assign a color pair to it calling wattron() (for example, I want to fill a window with blue background), and then I call my own function wnd_fill() :
Code: void wnd_fill (WINDOW* wnd)
{
int i;
[code]...
View 9 Replies
View Related
Mar 27, 2011
I have a script that calls another program/script, xxx, to run in the background. Supposedly this program at most should finish within five (5) minutes so after five (5) minutes, I run some other steps to run the script into completion. My problem is sometimes the program takes longer than five (5) minutes and this is causing problems when running the rest of the steps in the scripts. Can anyone suggest how to re-program my script. At the moment, the KSH script, i.e. test.ksh, is doing as below:
test.ksh:
.....
.....
xxx/xxx.ksh <--- program/script called by the script
sleep 300
..... run the rest of the script .....
..... problem is sometimes xxx/xxx.ksh takes longer than 300 seconds .....
..... any way that I can monitor that xxx/xxx.ksh finishes before I run .....
..... the rest of the scripts .....
View 3 Replies
View Related
May 18, 2011
I am doing a program that reads data from a gps and some other devices and writes some files with all the information. When I run it normally it works fine, but if I run the program in the background (with the ampersand) files are not created until I bring it to foreground or close it. I am confused, the program should run the same way with and without the ampersand. (Could it be that the main process that creates all the threads does not create them when it is executed in background? It seems like if the program is stopped until I take it to the foreground).
View 4 Replies
View Related