Announcement

Collapse
No announcement yet.

Engine Code: Copy console to Clipboard

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Engine Code: Copy console to Clipboard

    Adding concopy command to Quake

    Type concopy in the console and all that text is now on your clipboard and you can paste it somewhere, instead of the various hassle methods of using condump (if you use an engine with that) or using -condebug + qconsole.log.

    Will be in the next incremental ProQuake 3.99 update (version m).

    In console.c (adapted from FitzQuake's condump command)

    Code:
    /*
    ================
    Con_Copy_f -- Baker -- adapted from Con_Dump
    ================
    */
    void Con_Copy_f (void)
    {
    	char	outstring[CON_TEXTSIZE]="";
    	int		l, x;
    	char	*line;
    	char	buffer[1024];
    
    	// skip initial empty lines
    	for (l = con_current - con_totallines + 1 ; l <= con_current ; l++)
    	{
    		line = con_text + (l%con_totallines)*con_linewidth;
    		for (x=0 ; x<con_linewidth ; x++)
    			if (line[x] != ' ')
    				break;
    		if (x != con_linewidth)
    			break;
    	}
    
    	// write the remaining lines
    	buffer[con_linewidth] = 0;
    	for ( ; l <= con_current ; l++)
    	{
    		line = con_text + (l%con_totallines)*con_linewidth;
    		strncpy (buffer, line, con_linewidth);
    		for (x=con_linewidth-1 ; x>=0 ; x--)
    		{
    			if (buffer[x] == ' ')
    				buffer[x] = 0;
    			else
    				break;
    		}
    		for (x=0; buffer[x]; x++)
    			buffer[x] &= 0x7f;
    
    		strcat(outstring, va("%s\r\n", buffer));
    
    	}
    
    	Sys_CopyToClipboard(outstring);
    	Con_Printf ("Copied console to clipboard\n");
    }
    In Con_Init in console.c

    Code:
    Cmd_AddCommand ("concopy", Con_Copy_f); // Baker - copy console to clipboard
    In sys_win.c (straight out of FuhQuake)

    Code:
    // copies given text to clipboard
    void Sys_CopyToClipboard(char *text) {
    	char *clipText;
    	HGLOBAL hglbCopy;
    
    	if (!OpenClipboard(NULL))
    		return;
    
    	if (!EmptyClipboard()) {
    		CloseClipboard();
    		return;
    	}
    
    	if (!(hglbCopy = GlobalAlloc(GMEM_DDESHARE, strlen(text) + 1))) {
    		CloseClipboard();
    		return;
    	}
    
    	if (!(clipText = GlobalLock(hglbCopy))) {
    		CloseClipboard();
    		return;
    	}
    
    	strcpy((char *) clipText, text);
    	GlobalUnlock(hglbCopy);
    	SetClipboardData(CF_TEXT, hglbCopy);
    
    	CloseClipboard();
    }
    In sys.h

    Code:
    void Sys_CopyToClipboard(char *);
    /The End

    Works fine in ProQuake and should be compatible with any engine very similar to WinQuake/GLQuake.
    Quakeone.com - Being exactly one-half good and one-half evil has advantages. When a portal opens to the antimatter universe, my opposite is just me with a goatee.

    So while you guys all have to fight your anti-matter counterparts, me and my evil twin will be drinking a beer laughing at you guys ...

  • #2
    What happens if you do a concopy then paste in the console?

    Sounds like something I would do by mistake.
    "It may disturb you. It scares the willies out of me. " -Slartibartfast

    Comment


    • #3
      It would paste 1 line.

      I've accidentally tried to paste a huge chunk of code into the console before. Obviously, you can't.
      Quakeone.com - Being exactly one-half good and one-half evil has advantages. When a portal opens to the antimatter universe, my opposite is just me with a goatee.

      So while you guys all have to fight your anti-matter counterparts, me and my evil twin will be drinking a beer laughing at you guys ...

      Comment


      • #4
        Cool. I always wanted that. I hope Rook adds it to Qrack.

        Any plans for some kind of "goto link" functionality? Or a link grabber like in mIRC?

        Comment


        • #5
          Originally posted by gulliver-trans View Post
          Cool. I always wanted that. I hope Rook adds it to Qrack.
          That's one of the reasons why I posted here. :d

          Who needs -condebug any more if you have condump and this.

          Btw, I think I'm just going to call this "copy" instead of "concopy". I think this might be used fairly often and giving it a name that can be forgotten by someone is silly.

          No one will forget "copy" and if you are typing it in the console, it's pretty clear what it is going to copy.

          Any plans for some kind of "goto link" functionality? Or a link grabber like in mIRC?
          Hmmm ... at first I was going to say no to that first thing.

          But thinking about this, I'm not so sure now. This would allow me to make a command in the console to open the default browser to a ProQuake online manual or FAQ.

          As for general links, I really don't see the point unless someone can come up with a REALLY good reason for why it would be needed.

          Other possible plans:

          1. Automatically connect to server via web browser.
          2. Maybe a "diag" command or something that copies important info (Operating system, video card type, which Quake it is, name of Quake folder) to the clipboard for all these "Quake help threads".
          3. Maybe an "openquake" command that opens up the Quake folder in explorer.

          Or I might try to figure out how to put these in the F1 help menu.
          Quakeone.com - Being exactly one-half good and one-half evil has advantages. When a portal opens to the antimatter universe, my opposite is just me with a goatee.

          So while you guys all have to fight your anti-matter counterparts, me and my evil twin will be drinking a beer laughing at you guys ...

          Comment


          • #6
            ok here is the scenario:

            *player1 connects to server*
            player1: "moh! no map!"
            player2: "download map at: http://shub-hub.com/files/maps_multiplayer/aerowalk.zip"
            player1: "ok cheers!"
            *player1 types "goto link" in console*

            this will open up his default browser and all he needs to do is press "save as / open"
            i know u are working on a better way of downloading maps.. but still.. it can be useful for any kind of quick and easy URL sharing wile on server..

            off course like any bit of technology it might be used to spam harmful links or whatever.. but then again.. the players will open the links on there own risk..
            Last edited by =peg=; 01-28-2008, 01:46 AM.

            Comment


            • #7
              Originally posted by =peg= View Post
              ok here is the scenario ...

              i know u are working on a better way of downloading maps.. but still.. it can be useful for any kind of quick and easy URL sharing wile on server..
              You are on to something there. But I think the example isn't very good for a few different reasons, including that isn't a standard Quake command.

              What might be "ok" is if someone messagemodes something with http:// or www. in it, if it took the URL and stored it (with conprint saying "you have received a link, type url in console to open it in your browser") allow someone to type a command in the console to navigate to that link if they choose.

              Something I want to do is make these commands unavailable except if they are typed in the console. i.e., a server can't activate it and it can't be in a config, etc.

              But you are on to something. The idea needs to be clean enough that no one would view it as a hack or awkward.
              Quakeone.com - Being exactly one-half good and one-half evil has advantages. When a portal opens to the antimatter universe, my opposite is just me with a goatee.

              So while you guys all have to fight your anti-matter counterparts, me and my evil twin will be drinking a beer laughing at you guys ...

              Comment


              • #8
                yeah that is what i had in mind..

                Comment


                • #9
                  If you wanted map downloading adding some way to use curl in the engine would be better (as in Darkplaces). Add zip support to it and be awesome. I requested that for ezQuake but it seems to be very low priority or not considered at all.
                  Quake 1 Singleplayer Maps and Mods

                  Comment


                  • #10
                    Originally posted by Spirit View Post
                    If you wanted map downloading adding some way to use curl in the engine would be better (as in Darkplaces). Add zip support to it and be awesome. I requested that for ezQuake but it seems to be very low priority or not considered at all.
                    If you have any thoughts on single player mod installation or automatic map download, I'd be really interested in hearing them.

                    I do things very incrementally, so aguirRe or someone else could, if they wanted to, add stuff to another engine without too much trouble from just about anything I've been working on.

                    I've looked thru DarkPlaces, FTE and Quakeworld for ideas on how to handle map download (curl method, http download, DP protocol method, QW protocol method).

                    I'd really like things to be nicer for single player use as well, not just multiplayer, but single player gets into complexities of course.

                    I will talk more about this some other time, but I *do* know of some things that would be needed for automatic mod installation that would require extra information. I mean, the Game-A-Tron does exactly that. But it needs about 10 extra fields to know how to handle the process. Maybe altering the Quaddicted database for this or having a Quaddicted-auto-generated .txt file with this info would be a good fit.
                    Last edited by Baker; 01-28-2008, 03:39 AM.
                    Quakeone.com - Being exactly one-half good and one-half evil has advantages. When a portal opens to the antimatter universe, my opposite is just me with a goatee.

                    So while you guys all have to fight your anti-matter counterparts, me and my evil twin will be drinking a beer laughing at you guys ...

                    Comment

                    Working...
                    X