LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-26-2012, 04:52 PM   #1
Benny7440
Member
 
Registered: Jul 2009
Location: Puerto Rico
Distribution: Puppy Linux 528
Posts: 204

Rep: Reputation: 19
How to grasp full control of the screen within a c program?


I remember that from a very basic BASIC running machine I had that capabilities at hand, by default, since the early '80's.

How can I achieve the same results from c?

For ex., I've seen that there're some codes that render the dominoes pieces or cards as used in poker. I need to use some symbols like those & they need to be placed in the screen at arbitrary locations & orientations. Need to change the background color without loosing any symbol present there already.

It should be possible but I don't know where to look for it. Thanks for any tip/help on this!
 
Old 04-26-2012, 05:18 PM   #2
dugan
Senior Member
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 4,614

Rep: Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415
Quote:
Originally Posted by Benny7440 View Post
I've seen that there're some codes that render the dominoes pieces or cards as used in poker.
I don't understand the question, but I might if you post a link to those "codes".

If you're writing a text-based user interface, then use ncurses or something similar.

If it's graphical, then look for a sprite library.

Last edited by dugan; 04-26-2012 at 05:22 PM.
 
1 members found this post helpful.
Old 04-26-2012, 05:45 PM   #3
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
You might want to look at the SDL library.
 
1 members found this post helpful.
Old 04-27-2012, 03:40 PM   #4
Benny7440
Member
 
Registered: Jul 2009
Location: Puerto Rico
Distribution: Puppy Linux 528
Posts: 204

Original Poster
Rep: Reputation: 19
Thanks for replying to both of you, dugan & jschiwal!

First to dugan: I'm sorry I was not clear enough, so lets try to correct that right now. Somewhere some months ago I was trying to have a keyboard enabled to write all the characters in English AWA in Spanish. A fellow told me that with a Ctl+U+"a 4 number with the keypad (maybe with Alt+#) I should be able to obtain any character desired. Right now I'm having a mess in my system & tried to obtain a few of them but its faults disable me to obtain any. I hope that with the info offered above you will know of what I was speaking of.

Now to jschiwal: I made a quick search of what you said & now I'm convinced that it wont be specially easy. First of all, I need to fix my system because I tried to run some simple c programs that were running smoothly before but the system respond with:
"no a command" type message.

I'll be posting back anything new that happens with all this in about a week or sooner...hope so!
 
Old 04-27-2012, 04:00 PM   #5
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,530
Blog Entries: 2

Rep: Reputation: 4024Reputation: 4024Reputation: 4024Reputation: 4024Reputation: 4024Reputation: 4024Reputation: 4024Reputation: 4024Reputation: 4024Reputation: 4024Reputation: 4024
I can't see how this question is related to your first post. Anyways, to write Unicode characters the proper key combination is Ctrl+Shift+u, then type in the four digit number, you don't need the keypad or pressing a different key, just type in the number.
 
1 members found this post helpful.
Old 04-27-2012, 04:51 PM   #6
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942
For console (text), you can use ANSI escape sequences, and if it supports UTF-8, Unicode glyphs:
Code:
printf '\033[31;47m \xe2\x99\xa5 \033[0m\n'
printf '\033[31;47m \xe2\x99\xa6 \033[0m\n'
printf '\033[30;47m \xe2\x99\xa3 \033[0m\n'
printf '\033[30;47m \xe2\x99\xa0 \033[0m\n'
The Unicode glyphs used above are U+2665, U+2666, U+2663, and U+2660 respectively. To control the location, you could use ANSI escape sequences, but it is a bit tricky.

I recommend using the ncursesw library instead. The *w version has support for "wide" characters, allowing you to use Unicode glyphs with ncurses. The ncurses programming howto is available in the ncurses-doc package, and for example here. Ncurses itself is almost always installed, but you might have to install the ncurses-dev package containing the development headers for writing new ncurses programs.

Like TobiSGD said, you can also type those glyphs by typing Ctrl+Shift+U, 2, 6, 6, 5, Ctrl. The final Ctrl can be any meta-key, as it just switches back to the normal node. Note that you only keep Ctrl and Shift depressed for the U, not for the numbers. Use the Character Map accessory available in most Linux desktop environments to search for specific glyphs; it also lists the Unicode code point.
 
1 members found this post helpful.
Old 04-28-2012, 09:29 AM   #7
Benny7440
Member
 
Registered: Jul 2009
Location: Puerto Rico
Distribution: Puppy Linux 528
Posts: 204

Original Poster
Rep: Reputation: 19
Thanks for replying to both of you, TobiSGD & Nominal Animal!

I'm sorry I didn't include the whole wording (unicodes) because I lost the grasp of the word at the time of posting. For ex., if you enter <Ctl+Shift+U + 9856> you should obtain something resembling half of the tile (0:1) in the dominoes game. So, it had some relationship with the 1st post.

I went to a site showing the ANSI character maps & screen controls but my console isn't able to do anything logical out of it. I think it has to do more with the mess I created when trying to delete some d/l program (Glade, I think) from Seamonkey File Finder, one or more libs needed by my system & possibly other files got deleted by myself: many entries from my menus aren't present anymore or for those still there some simply do nothing.

I'll keep the info both of you posted handy for trying them after I fix the system.
 
Old 04-28-2012, 11:19 AM   #8
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942
Quote:
Originally Posted by Benny7440 View Post
For ex., if you enter <Ctl+Shift+U + 9856> you should obtain something resembling half of the tile (0:1) in the dominoes game.
I do believe you need to type in the hexadecimal value, not the decimal value. 9856 = 0x2680, and <Ctrl+Shift+U>2680<Shift> produces ⚀ for me. You can see if your terminal or console supports these Unicode glyphs by running command
Code:
printf '\xe2\x9a\x80\n'
Quote:
Originally Posted by Benny7440 View Post
one or more libs needed by my system & possibly other files got deleted by myself
Oh. If you have a Debian variant (Debian, Ubuntu, Mint), you can run
Code:
dpkg-query -l '*' | awk '($1=="ii") { print $2 }' | xargs dpkg-query -L | grep -v -e '^/etc' -e '^/usr/share' -e '^[\t\v\f ]*$' -e '^package diverts' -e '^diverted' | while read FILE ; do [ -L "$FILE" -o -e "$FILE" ] || echo "$FILE" ; done | xargs dpkg-query -S | cut -d ':' -f 1 | sort | uniq
It reports a few false positives (cups, gir1.2-dee-0.5, policykit-1, and policykit-desktop-privileges, on my system), does not detect files that are dynamically created at installation time, and does not check every single installed package, but it should catch anything obvious. You can reinstall affected packages using
Code:
sudo apt-get install --reinstall packages...
but note that some packages may overwrite any custom configuration you have done with their default configuration files.

On the other hand, if you can back up your files, doing a clean reinstall now and then feels refreshing

I mean, you get rid of old stuff you no longer need, and remove any backward compatibility packages lingering around (complicating things, just because you originally installed the machine years ago). While most distributions do QA, they normally only do that for a clean install. Reinstalling now and then -- especially after a critical mishap -- helps you avoid any corner cases. Considering the importance of backing up now and then, and the ease of installation of current Linux distributions, I think a good nice clean reinstall every year or so is not such a bad idea, overall. For me, the main point is making sure I have good backups, though; otherwise I tend to not bother, really. (I do use RAID-1 for my documents.)
 
1 members found this post helpful.
Old 04-29-2012, 09:41 PM   #9
Benny7440
Member
 
Registered: Jul 2009
Location: Puerto Rico
Distribution: Puppy Linux 528
Posts: 204

Original Poster
Rep: Reputation: 19
Thanks, Nominal Animal, for your reply!

Non of your commands above work for me except: printf '\xe2\x9a\x80\n'.

On all other cases it replied with "no such command or filename..."

The state of the machine is really bad!
 
Old 04-30-2012, 12:27 AM   #10
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942
What distribution are you using? What does
Code:
cat /etc/issue
output?
 
1 members found this post helpful.
Old 05-01-2012, 10:56 AM   #11
Benny7440
Member
 
Registered: Jul 2009
Location: Puerto Rico
Distribution: Puppy Linux 528
Posts: 204

Original Poster
Rep: Reputation: 19
Thanks Nominal Animal for replying!

The output of the command you posted is:

"sh-4.1# cat /etc/issue
Lucid Linux
Linux 2.6.33.2 [i686 arch]"

Hope this's what you asked me to post.
 
Old 05-01-2012, 09:13 PM   #12
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942
Quote:
Originally Posted by Benny7440 View Post
Hope this's what you asked me to post.
Yes. I do believe you'll save yourself a lot of grief if you can just do a clean reinstall. Just save all your files onto some other media (USB sticks, DVD-R's), and check you have everything before wiping the disk. As it happens, Ubuntu 12.04 LTS (five-year support span) was just released, so installing that one from scratch makes a lot of sense.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Uuntu 11.10:Ubuntu screen not occupying full screen of Presario-CQ57-Notebook PC jason805 Linux - Laptop and Netbook 1 04-01-2012 05:57 AM
[SOLVED] PlayOnLinux Game Launches in full screen with GNOME panel at end of screen LinusStallman Linux - Games 2 07-17-2011 01:23 PM
upgraded to kubuntu 11.4: screen flickers after full-screen openGL sonicboy Ubuntu 7 05-03-2011 09:31 PM
Slackware current goes to KDE login screen when I Esc from full-screen youtube videos Robert.Thompson Slackware 2 04-11-2011 04:43 PM
Full screen screen shots -- Screenshot program with hotkeys studpenguin Linux - General 1 03-10-2009 11:58 PM


All times are GMT -5. The time now is 05:10 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration