CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14

Thread: linux clipboard

  1. #1
    Join Date
    Aug 2003
    Posts
    27

    linux clipboard

    I am trying to write a console program that needs access to the clipboard, but I am having a hard time finding any info. Where can I find the clipboard functions? Are the functions the same in different Linux distributions? Can the functions be used in console mode, without desktop?

    Any help is appreciated
    Last edited by Aidman; January 13th, 2004 at 04:39 PM.
    We haven't inherited Earth from our parents; instead we have borrowed her from our children - old Indian saying.

  2. #2
    Join Date
    Jan 2004
    Posts
    20

    Re: linux clipboard

    Originally posted by Aidman
    I am trying to write a console program that needs access to the clipboard, but I am having a hard time finding any info. Where can I find the clipboard functions? Are the functions the same in different Linux distributions? Can the functions be used in console mode, without desktop?

    Any help is appreciated
    the X clipboard requires the X server (obviously ) See this link about cut buffers:

    http://tronche.com/gui/x/xlib/utilit...t-buffers.html

    otherwise, use selections. you'll have to do a certain amount of googling to get started with Xlib functions in either case. Good luck!
    Last edited by abc_coder; January 13th, 2004 at 07:43 PM.

  3. #3
    Join Date
    Aug 2003
    Posts
    27

    Thanks

    Do you kwow which of the two methods is most commenly used?
    And which method does shortcut keys like Ctrl+C and Ctrl+V rely on?
    Last edited by Aidman; January 14th, 2004 at 10:11 AM.
    We haven't inherited Earth from our parents; instead we have borrowed her from our children - old Indian saying.

  4. #4
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    I am not sure, but I thought that a Windows "console" program is a standard Linux/Unix program. Isn't the equivalent of a Windows "console" program just called a program in Linux/Unix?

    I am very curious to know if Linux/Unix has the eqivalent of a clipboard. I will be surprised if it does. Perhaps you are assuming too much about Linux/Unix. I know that there are some commonly-used GUIs for Linux/Unix (such as X Windows?) but they are separate from Linux/Unix, correct?

    As far as I know, Linux/Unix is strictly command-line ("console mode"). Unix programs have typically used device commands (many devices implemented ANSI standard commands) for display devices to provide full-screen text interfaces, and there is a "Curses" library that simplifies that. Linux/Unix has never implemented a GUI; it has always been separate; right?
    Last edited by Sam Hobbs; January 14th, 2004 at 03:07 PM.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  5. #5
    Join Date
    Nov 2003
    Location
    Vienna, Austria
    Posts
    212
    Some things about Linux...

    A program in Linux is just that, a program. You can have one and the same program be a console program or a GUI program, with only a parameter deciding. That's possible with Windows apps too, but I wonder how many people know how to do it...

    Anyway.

    GUIs in Linux can be console-based too (curses or ncurses), or real GUIs based on the X architecture.
    On top of the X architecture sits a window manager that draws window borders and stuff like that.
    On top of that and usually integrated with it might sit a desktop environment like KDE or Gnome.

    The most low-level programming interface of Linux is the C Runtime Library. The next level is the POSIX API, which provides more extensive file system operations, threading, piping and such stuff. It does not, to my knowledge, have any centralized and standardized data storage location (a clipboard). Named pipes could do something like that, but I don't think there's a "clipboard" pipe that you can rely on.

    curses and it's GNU counterpart ncurses are libraries that provide windows and controls that are drawn in character mode. They are AFAIK strictly limited to supporting the process that uses them, so they provide no means of communication either.

    Apparently the X server provides clipboard-like structures.

    But nearly no apps are written with Xlib, it's too complicated and low-level. GTK and Qt are usually the libraries of choice. Both provide clipboard-like features, but if they use the underlying X support I do not know.
    All the buzzt
    CornedBee

  6. #6
    Join Date
    Nov 2003
    Location
    Vienna, Austria
    Posts
    212
    Originally posted by Sam Hobbs
    Linux/Unix has never implemented a GUI; it has always been separate; right?
    Your terminology is mixed up, that's your main problem.

    Unix refers either to the original Unix operating system, developed by AT&T, and it's derivates (Berkely Unix, ...), or to the family of Unix-like operating systems: Linux, AT&T Unix, BSD and its clones, they are numerous.

    Linux is actually only an operating system kernel. By itself, it gives applications the means to access hardware and manages processes, theads and memory.
    Unfortunatly, it doesn't provide any means for user interactions, nor has it any way of loading itself on startup.
    Which is why the OS is correctly called GNU/Linux. An immense collection of tools developed by GNU and others surround the kernel, making it usable. LiLo or Grub for startup, sh, csh, bash, ... for user interaction.

    So, yes, Linux has never implemented anything graphical.

    However the X architecture has been implemented for the GNU/Linux OS, in the popular XFree86 project. This X server provides the means for real graphical user interfaces, and it is extensivly used. Completly developed desktop environments like Gnome and KDE have almost caught up with the user-friendliness of Windows and surpassed it in some regions. And they are based on the security, stability and flexibility of the GNU/Linux OS.
    All the buzzt
    CornedBee

  7. #7
    Join Date
    Nov 2003
    Location
    Vienna, Austria
    Posts
    212
    Oh yeah, http://cboard.cprogramming.com/ has a forum dedicated to Linux programming. Why not ask there?
    All the buzzt
    CornedBee

  8. #8
    Join Date
    Aug 2003
    Posts
    27
    You are probely right about my assumptions

    I have just started using Linux and therefore my choice of words might not be the best.
    Althougth I hope you did understand my question, which seems to be harder than I thought.

    I tested using the Cut-Buffer functions, but they didn't seem to be used by other applications,
    I couldn't get the buffers changed by copy/paste in other programs.

    I would really like to test using Selections, but I can't find any examples to get them working.
    They seems to requier a lot of parameters, some of which I don't even know if I can get without a window.

    Is there any resource pages for linux programming (equivalent to for ex. www.planet-source-code.com or www.codeproject.com)?
    We haven't inherited Earth from our parents; instead we have borrowed her from our children - old Indian saying.

  9. #9
    Join Date
    Nov 2003
    Location
    Vienna, Austria
    Posts
    212
    I forgot one part, about the default key combinations. For the standard controls, they are defined by the toolkit (GTK or Qt), but usually are Ctrl+C and Ctrl+V. The toolkit may take advice from the environment.

    For non-standard things, like in Windows, you must catch the shortcuts yourself, so you decide what they are.
    All the buzzt
    CornedBee

  10. #10
    Join Date
    Aug 2003
    Posts
    27
    Originally posted by CornedBee
    Oh yeah, http://cboard.cprogramming.com/ has a forum dedicated to Linux programming. Why not ask there?
    As you can see I already posted there
    but unfortunately I got 0 repiles.
    We haven't inherited Earth from our parents; instead we have borrowed her from our children - old Indian saying.

  11. #11
    Join Date
    Nov 2003
    Location
    Vienna, Austria
    Posts
    212
    Give 'em a little time.
    All the buzzt
    CornedBee

  12. #12
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    Originally posted by Aidman
    Is there any resource pages for linux programming (equivalent to for ex. www.planet-source-code.com or www.codeproject.com)?
    Try:

    LinuxQuestions.org - Where Linux newbies come for help! (not entirely programming help, but otherwise worth using)
    Linux Links - The Linux Portal
    Linux Journal - The Premier Magazine of the Linux Community
    The Linux Documentation Project
    IBM Linux Technology Center : Welcome
    freshmeat.net

    I don't know how useful some of those are, but you can look and decide yourself.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  13. #13
    Join Date
    Jan 2004
    Posts
    20
    Originally posted by Aidman
    I tested using the Cut-Buffer functions, but they didn't seem to be used by other applications,
    I couldn't get the buffers changed by copy/paste in other programs.
    that is because most X apps on't use them ... they're 'evil' the recommended practice is 'use selections'

    Originally posted by Aidman
    I would really like to test using Selections, but I can't find any examples to get them working.
    They seems to requier a lot of parameters, some of which I don't even know if I can get without a window.
    you need some determinate googling or fiddling through X reccomendations to figure stuff out; however, in your case it's somehow easier (not by much if you want to understand what's going on though ). there's an app that does exactly what you want, called xclip that you can check the source code for hints.

    the use of selections in X seems to be a bit strange coming from windows: one can request 3 atoms - XA_PRIMARY, XA_SECONDARY and XA_CLIPBOARD. The recommendation is for the first to be for highlight/middle-click paste, the second to go unused and the last to be for Ctrl-C/X/V - type communications.

  14. #14
    Join Date
    Aug 2003
    Posts
    27

    Thanks to all!

    Thanks for the links and help guys. I'm surely going to check them all out.
    Although I’m experiencing some beginner difficulties I still find the world of Linux all new and exciting, peace out
    We haven't inherited Earth from our parents; instead we have borrowed her from our children - old Indian saying.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured