LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 09-09-2019, 04:42 AM   #1
harshanev
LQ Newbie
 
Registered: Dec 2015
Posts: 11

Rep: Reputation: Disabled
cursor in Linux C


I would like to know how to set cursor in C linux. I cannot use printf.
 
Old 09-09-2019, 06:56 AM   #2
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: FreeBSD/Slackware-14.2+/ArcoLinux
Posts: 9,079

Rep: Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903
googlishious....


/*
* cursor.c - demonstrate creating mouse cursors and attaching them to
* a window.
*/


that one above, is a link to get a c file code that demonstrates this process.


https://tronche.com/gui/x/xlib/pixma...or/cursor.html

Last edited by BW-userx; 09-09-2019 at 06:58 AM.
 
2 members found this post helpful.
Old 09-09-2019, 08:05 AM   #3
harshanev
LQ Newbie
 
Registered: Dec 2015
Posts: 11

Original Poster
Rep: Reputation: Disabled
my question was more to do with setting up in VGA.
 
Old 09-09-2019, 08:44 AM   #4
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: FreeBSD/Slackware-14.2+/ArcoLinux
Posts: 9,079

Rep: Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903
Quote:
Originally Posted by harshanev View Post
my question was more to do with setting up in VGA.
you didn't say that. go look at all of the information you gave, or lack thereof.
I am not a mind reader.

Last edited by BW-userx; 09-09-2019 at 08:46 AM.
 
Old 09-09-2019, 08:56 AM   #5
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 9,094

Rep: Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931
My quick Google search for that says:

Use tput cup if it's available.

And if it isn't, then use ANSI escape sequences.

https://unix.stackexchange.com/quest...erminal-window
https://rosettacode.org/wiki/Termina...ng#C.2FC.2B.2B
 
1 members found this post helpful.
Old 09-09-2019, 09:09 AM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: MA, USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 8,010
Blog Entries: 13

Rep: Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451
Quote:
Originally Posted by harshanev View Post
I would like to know how to set cursor in C linux. I cannot use printf.
Quote:
Originally Posted by harshanev View Post
my question was more to do with setting up in VGA.
As cited by one of your fellow members, we all cannot read minds, or know exactly what is meant by your original question.

What exactly do you mean by "set cursor"?

Configure it?
Place it somewhere?

Adding in VGA ... I'll have to admit that I have nearly zero idea what this means.

I do realize that there is a cursor, and the video drivers of the system have some interaction as to how a cursor is drawn, or shown, and also the concept of where the cursor is positioned.

Still, I can, as well as fellow members can, guess all we want. We'd rather help with a clear description of your question and problem.
 
1 members found this post helpful.
Old 09-09-2019, 09:18 AM   #7
harshanev
LQ Newbie
 
Registered: Dec 2015
Posts: 11

Original Poster
Rep: Reputation: Disabled
I am trying to write a small os in c. VGA memory part is refreshed to screen so many times a second. Only choice I have is write in ASSEMBLER.
 
Old 09-09-2019, 09:50 AM   #8
rtmistler
Moderator
 
Registered: Mar 2011
Location: MA, USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 8,010
Blog Entries: 13

Rep: Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451Reputation: 3451
Quote:
Originally Posted by harshanev View Post
I am trying to write a small os in c. VGA memory part is refreshed to screen so many times a second. Only choice I have is write in ASSEMBLER.
So what exactly are your specific needs?

Perhaps you can provide some more information about what you have written in assembler as an example of the challenges you are trying to accomplish in the C language.

If it has to do with accessing, testing, and modifying a specific memory location, the C language can do this. Basically you'd be writing gets and puts library functions to work with your OS.

Or are there questions you have specifically about the VGA interface where you do not understand exactly how you can specify I/O correctly?
 
1 members found this post helpful.
Old 09-09-2019, 11:05 AM   #9
harshanev
LQ Newbie
 
Registered: Dec 2015
Posts: 11

Original Poster
Rep: Reputation: Disabled
//Prints a "X" on the upper-left corner
char * vga;
int i;
vga = (char *) 0xb8000;
*vga = 'C';
++vga;
*vga = BLACK_ON_WHITE;
++vga;
*vga = 'E';
++vga;
*vga = BLACK_ON_WHITE;
for (i=4;i<1100;i++)
{ ++vga;
*vga = 0;
++vga;
};

Above is how you display C E on top left position in C programming language. But cursor is some where else.

This is how you to set cursor in Assembler.

os_move_cursor:^M
pusha^M
^M
mov bh, 0^M
mov ah, 2^M
int 10h ; BIOS interrupt to move cursor^M
^M
popa^M
ret^M
^M
^M
 
Old 09-09-2019, 11:18 AM   #10
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 12,995

Rep: Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097
would be nice to use code tags, that will keep the original formatting of your code.
Most probably you need to implement your cursor movement, because in your environment cursor is not handled currently (= you need to implement it too).
 
1 members found this post helpful.
Old 09-09-2019, 11:24 AM   #11
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 3,844

Rep: Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320
Check this SO question: https://stackoverflow.com/questions/...protected-mode
 
1 members found this post helpful.
Old 09-09-2019, 11:56 AM   #12
harshanev
LQ Newbie
 
Registered: Dec 2015
Posts: 11

Original Poster
Rep: Reputation: Disabled
Hi Pan64

Any idea how to implement cursor movement in c?
 
Old 09-09-2019, 12:26 PM   #13
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 3,844

Rep: Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320
Kindly belive us: cursor, terminal, BIOS etc aren't part of C-language.

Your question would be Linux/x86/PC-specific, except you don't wish to use Linux. So your question is x86/PC-specific.

Basically you wish to use BIOS in protected mode.
 
1 members found this post helpful.
Old 09-09-2019, 03:13 PM   #14
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_12{.0|.1}
Posts: 5,175
Blog Entries: 11

Rep: Reputation: 3094Reputation: 3094Reputation: 3094Reputation: 3094Reputation: 3094Reputation: 3094Reputation: 3094Reputation: 3094Reputation: 3094Reputation: 3094Reputation: 3094
@harshanev: Please review the Site FAQ for guidance in posting your questions and general forum usage. Especially, read the link in that page, How To Ask Questions The Smart Way. The more effort you put into understanding your problem and framing your questions, the better others can help!
 
Old 09-09-2019, 05:59 PM   #15
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,498

Rep: Reputation: 1806Reputation: 1806Reputation: 1806Reputation: 1806Reputation: 1806Reputation: 1806Reputation: 1806Reputation: 1806Reputation: 1806Reputation: 1806Reputation: 1806
Quote:
Originally Posted by harshanev View Post
I am trying to write a small os in c.
So is this a question about Linux (as in the title) or for your own OS?
 
2 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
Hide mouse cursor/change cursor location? mrjamin Linux - Software 4 09-27-2010 10:09 AM
Fedora cursor changed to Xorg cursor ArchNGEL Linux - Desktop 2 03-14-2007 07:21 PM
Could not open default cursor font 'cursor' at startx with slackware 10.2 bgryderclock Slackware 3 01-02-2006 10:36 PM
[Mouse cursor] flicking on animated cursor Creak Debian 1 06-10-2005 02:16 AM
Changin cursor -obtaining cursor isaac_linux Linux - General 1 11-05-2003 12:48 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:19 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration