From michael@stoichiometry.net Tue Mar 29 14:49:18 2005 From: Michael To: textmate@lists.macromates.com Subject: [TxMt] & drag commands Date: Tue, 29 Mar 2005 15:49:14 +0100 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1474960657689925284==" --===============1474960657689925284== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit I was wondering if anyone had got the built-in HTML drag commands for and to work in Textmate 1b5? Currently if I drag a html or PDF file from the project window into a HTML file I'm working on it will create a link, but if I drag an image file or css file onto the HTML file, Textmate will insert the raw source of the dragged file. Any ideas where I am going wrong? I am using the following drag commands (built-in): File Types: png, PNG, jpeg, JPEG, jpg, JPG, gif, GIF Commands: img=$TM_DROPPED_FILE alt=`echo $img | perl -pe 's/^(.*\/)?(.*?)(\..*)?$/$2/g' | tr '_-' ' '` sips -g pixelWidth -g pixelHeight $img | awk '/pixelWidth/ { w=$2 } /pixelHeight/ { h=$2 } END { printf("\"${0:'"$alt"'}\"", w, h) }' File Types: css echo "" Apologies if this has already been covered. Mike --===============1474960657689925284==-- From allan@macromates.com Tue Mar 29 18:32:19 2005 From: Allan Odgaard To: textmate@lists.macromates.com Subject: Re: [TxMt] & drag commands Date: Tue, 29 Mar 2005 17:46:23 +0200 Message-ID: <67e715c5aa6435c880a82981a05ede80@macromates.com> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3169259629123793202==" --===============3169259629123793202== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On Mar 29, 2005, at 16:49, Michael wrote: > I was wondering if anyone had got the built-in HTML drag commands for > and to work in Textmate 1b5? It works for me. What's not apparent from the bundle editor is that currently the extension of the file in which you drop the image is used to figure out which drag command to execute. In the future this will be changed to instead rely on the scope, but for now the HTML file should have one of these extensions: html, htm, rhtml, shtml, phtml, php, php3, php4, php5, inc, cfm, cfml, dbm, dbml. You can edit the drag command outside TextMate if you're using another extension for your files. > Currently if I drag a html or PDF file from the project window into a > HTML file I'm working on it will create a link, but if I > drag an image file or css file onto the HTML file, Textmate will > insert the raw source of the dragged file. Hmm... judging from this, your document does have the proper extension. Which extension does the dragged CSS or image file have? --===============3169259629123793202==-- From todd@slack.net Tue Mar 29 19:29:17 2005 From: Todd Grimason To: textmate@lists.macromates.com Subject: Re: [TxMt] & drag commands Date: Tue, 29 Mar 2005 11:26:31 -0500 Message-ID: <20050329162631.GB27997@detroit.slack.net> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8627303931293445176==" --===============8627303931293445176== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit * Michael [2005-03-29 09:51]: > I was wondering if anyone had got the built-in HTML drag commands for > and to work in Textmate 1b5? > > Currently if I drag a html or PDF file from the project window into a > HTML file I'm working on it will create a link, but if I > drag an image file or css file onto the HTML file, Textmate will insert > the raw source of the dragged file. > > Any ideas where I am going wrong? I am using the following drag > commands (built-in): > This totally doesn't answer your question, but I've noticed in some cases I'll get an img tag, other cases the binary code. Unfortunately I've always been rushed and not had a chance to examine the context. I have the default (built-in) commands as well... I suspect it's based on the context - file type or location in file, or something... -- ______________________________ toddgrimason*todd-AT-slack.net --===============8627303931293445176==-- From michael@stoichiometry.net Wed Mar 30 10:34:55 2005 From: Michael To: textmate@lists.macromates.com Subject: Re: [TxMt] & drag commands Date: Wed, 30 Mar 2005 11:34:40 +0100 Message-ID: <6781c4770833400c9eef2bb0b17b908e@stoichiometry.net> In-Reply-To: <67e715c5aa6435c880a82981a05ede80@macromates.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7191271776195003376==" --===============7191271776195003376== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On 29 Mar 2005, at 16:46, Allan Odgaard wrote: > On Mar 29, 2005, at 16:49, Michael wrote: > >> I was wondering if anyone had got the built-in HTML drag commands for >> and to work in Textmate 1b5? > > It works for me. What's not apparent from the bundle editor is that > currently the extension of the file in which you drop the image is > used to figure out which drag command to execute. > > In the future this will be changed to instead rely on the scope, but > for now the HTML file should have one of these extensions: html, htm, > rhtml, shtml, phtml, php, php3, php4, php5, inc, cfm, cfml, dbm, dbml. > > You can edit the drag command outside TextMate if you're using another > extension for your files. > >> Currently if I drag a html or PDF file from the project window into >> a HTML file I'm working on it will create a link, but if >> I drag an image file or css file onto the HTML file, Textmate will >> insert the raw source of the dragged file. > > Hmm... judging from this, your document does have the proper > extension. Which extension does the dragged CSS or image file have? .css and .jpg Interestingly this morning after re-launching Textmate when I drag and drop an image I get: Error 4: no file was specified Try 'sips --help' for help using this tool but still get the source of a css file when dragged and dropped. > > ______________________________________________________________________ > For new threads USE THIS: textmate(a)lists.macromates.com > (threading gets destroyed and the universe will collapse if you don't) > http://lists.macromates.com/mailman/listinfo/textmate --===============7191271776195003376==-- From allan@macromates.com Wed Mar 30 13:48:18 2005 From: Allan Odgaard To: textmate@lists.macromates.com Subject: Re: [TxMt] & drag commands Date: Wed, 30 Mar 2005 15:48:12 +0200 Message-ID: In-Reply-To: <6781c4770833400c9eef2bb0b17b908e@stoichiometry.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5171194155250075757==" --===============5171194155250075757== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On Mar 30, 2005, at 12:34, Michael wrote: > Interestingly this morning after re-launching Textmate when I drag and > drop an image I get: > > Error 4: no file was specified I just noticed that the $TM_DROPPED_FILE variable (and $img) should have been quoted in the drag command (in case the file path contains a space), though I'd think this would give another error code. Could you try to change the drag command simply to: echo $TM_DROPPED_FILE That should then output the path dropped (relative to the directory of the file). --===============5171194155250075757==-- From michael@stoichiometry.net Wed Mar 30 14:06:01 2005 From: Michael To: textmate@lists.macromates.com Subject: Re: [TxMt] & drag commands Date: Wed, 30 Mar 2005 15:05:57 +0100 Message-ID: <2f983a4e6a5ac4a1d5eaec788a8c6665@stoichiometry.net> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8111476729643597762==" --===============8111476729643597762== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On 30 Mar 2005, at 14:48, Allan Odgaard wrote: > On Mar 30, 2005, at 12:34, Michael wrote: > >> Interestingly this morning after re-launching Textmate when I drag >> and drop an image I get: >> >> Error 4: no file was specified > > I just noticed that the $TM_DROPPED_FILE variable (and $img) should > have been quoted in the drag command (in case the file path contains a > space), though I'd think this would give another error code. > > Could you try to change the drag command simply to: > echo $TM_DROPPED_FILE > > That should then output the path dropped (relative to the directory of > the file). Thanks: that works - with just the path to the file being inserted. How do I modify it so that when I drag an image file to a document I get: and for css: Cheers, Mike --===============8111476729643597762==-- From allan@macromates.com Wed Mar 30 14:21:14 2005 From: Allan Odgaard To: textmate@lists.macromates.com Subject: Re: [TxMt] & drag commands Date: Wed, 30 Mar 2005 16:21:00 +0200 Message-ID: In-Reply-To: <2f983a4e6a5ac4a1d5eaec788a8c6665@stoichiometry.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0955509292717675364==" --===============0955509292717675364== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On Mar 30, 2005, at 16:05, Michael wrote: >> Could you try to change the drag command simply to: >> echo $TM_DROPPED_FILE > Thanks: that works - with just the path to the file being inserted. Does it use the command then both for your image and CSS? or did you make the change for both drag commands? > How do I modify it so that when I drag an image file to a document I > get: > alt="" /> > > and for css: > media="my_choice"/> Well... that's really what the default stuff should have done ;) For CSS try then to change the drag command to: printf '\n' "$TM_DROPPED_FILE" And let me know if that works. --===============0955509292717675364==-- From michael@stoichiometry.net Wed Mar 30 14:30:14 2005 From: Michael To: textmate@lists.macromates.com Subject: Re: [TxMt] & drag commands Date: Wed, 30 Mar 2005 15:30:04 +0100 Message-ID: <19d1d6c2f9391d03612f7242cf49814b@stoichiometry.net> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4699317977469304911==" --===============4699317977469304911== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On 30 Mar 2005, at 15:21, Allan Odgaard wrote: > On Mar 30, 2005, at 16:05, Michael wrote: > >>> Could you try to change the drag command simply to: >>> echo $TM_DROPPED_FILE >> Thanks: that works - with just the path to the file being inserted. > > Does it use the command then both for your image and CSS? or did you > make the change for both drag commands? I only modified the image drag command, and when I tried to drag a css file it still inserted the source of the file, but after trying the drag command listed below for css it works fine - thanks. Any suggestions for the image drag command? > >> How do I modify it so that when I drag an image file to a document I >> get: >> > alt="" /> >> >> and for css: >> > media="my_choice"/> > > Well... that's really what the default stuff should have done ;) > > For CSS try then to change the drag command to: > printf ' media="my_choice"/>\n' "$TM_DROPPED_FILE" > > And let me know if that works. --===============4699317977469304911==-- From allan@macromates.com Wed Mar 30 14:41:56 2005 From: Allan Odgaard To: textmate@lists.macromates.com Subject: Re: [TxMt] & drag commands Date: Wed, 30 Mar 2005 16:41:44 +0200 Message-ID: <4d6c1a0ccfbc49962ba0e006c3d979f1@macromates.com> In-Reply-To: <19d1d6c2f9391d03612f7242cf49814b@stoichiometry.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1270930374985524560==" --===============1270930374985524560== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On Mar 30, 2005, at 16:30, Michael wrote: >> Does it use the command then both for your image and CSS? or did you >> make the change for both drag commands? > I only modified the image drag command, and when I tried to drag a css > file it still inserted the source of the file, but after trying the > drag command listed below for css it works fine - thanks. > > Any suggestions for the image drag command? Well, try to restore it to: img="$TM_DROPPED_FILE" alt=`echo $img | perl -pe 's/^(.*\/)?(.*?)(\..*)?$/$2/g' | tr '_-' ' '` sips -g pixelWidth -g pixelHeight "$img" | awk '/pixelWidth/ { w=$2 } /pixelHeight/ { h=$2 } END { printf("\"${0:'"$alt"'}\"", w, h) }' If this fails, try one thing at a time, e.g. just: sips -g pixelWidth -g pixelHeight "$TM_DROPPED_FILE" Btw: if you have an IRC client, msg me on #textmate / FreeNode, that's a bit easier than this... --===============1270930374985524560==-- From allan@macromates.com Wed Mar 30 14:55:02 2005 From: Allan Odgaard To: textmate@lists.macromates.com Subject: Re: [TxMt] & drag commands Date: Wed, 30 Mar 2005 16:54:43 +0200 Message-ID: In-Reply-To: <6781c4770833400c9eef2bb0b17b908e@stoichiometry.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5778954002810983671==" --===============5778954002810983671== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On Mar 30, 2005, at 12:34, Michael wrote: > [...] Interestingly this morning after re-launching Textmate when I > drag and drop an image I get: Which reminds me, editing the drag commands currently does require a restart before the changes take effect, sorry. --===============5778954002810983671==-- From michael@stoichiometry.net Wed Mar 30 15:00:10 2005 From: Michael To: textmate@lists.macromates.com Subject: Re: [TxMt] & drag commands Date: Wed, 30 Mar 2005 15:59:59 +0100 Message-ID: <06bf36c8a3d608562e01b12f4a1ef91c@stoichiometry.net> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7242327845219563927==" --===============7242327845219563927== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On 30 Mar 2005, at 15:54, Allan Odgaard wrote: > On Mar 30, 2005, at 12:34, Michael wrote: > >> [...] Interestingly this morning after re-launching Textmate when I >> drag and drop an image I get: > > Which reminds me, editing the drag commands currently does require a > restart before the changes take effect, sorry. Thanks for the image drag command - this now works. I had guessed that a re-launch was required for changes to take effect - but thanks for the confirmation. > > ______________________________________________________________________ > For new threads USE THIS: textmate(a)lists.macromates.com > (threading gets destroyed and the universe will collapse if you don't) > http://lists.macromates.com/mailman/listinfo/textmate --===============7242327845219563927==-- From info@ideacog.net Wed May 25 19:53:56 2005 From: Ben Parzybok To: textmate@lists.macromates.com Subject: Re: [TxMt] & drag commands Date: Wed, 25 May 2005 12:53:50 -0700 Message-ID: <17D59CE5-5C7A-4B12-AC68-582F9A2426D1@ideacog.net> In-Reply-To: <4d6c1a0ccfbc49962ba0e006c3d979f1@macromates.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8542482094838709414==" --===============8542482094838709414== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Hi, I'm reviving this somewhat old thread on dragging images (and css) into an open html file. I'm unable to get an tag when I try to drag an image into an open html file, I get only the very long binary write-out. I've tried playing with the snippet as per this thread (dated March '05). I'm using 1.09b with a refreshed svn checkout (as of 5/25/05). Just for the fun of it, I just removed all my local bundles ~/Library/ Application Support/Textmate in case some setting I'd created was overwriting the new bundles (I may be confused on how this works, but I think it's like this) I have: img=$TM_DROPPED_FILE alt=`echo $img | perl -pe 's/^(.*\/)?(.*?)(\..*)?$/$2/g' | tr '_-' ' '` echo -n "![\${1:$alt}]($TM_DROPPED_FILE)" as the Drag command in the bundle editor. (under Markdown/Insert tag) Applying to these file types: png, PNG, jpeg, JPEG, jpg, JPG, gif, GIF This hasn't worked for me on the last couple of betas, and I've neglected to take the time to figure out if it was something I did or was the result of the new beta development. Since I haven't heard anyone mention it, I'm guessing I frigged w/ something at one time. I just tried: sips -g pixelWidth -g pixelHeight "$TM_DROPPED_FILE" in place of the drag command above, but I still get binary output instead of an tag w/ the path. Is it possible I have one drag command taking precedence over the one I'm looking at? --OK, I just listed only drag commands and found there was also a Latex img drag command. I've tried removing the latex bundle, restarting, trying the drag command. Then replacing latex, removing markdown bundle and trying drag command. Still no go. Does anyone have any suggestions? Thanks in advance, Ben On Mar 30, 2005, at 6:41 AM, Allan Odgaard wrote: > On Mar 30, 2005, at 16:30, Michael wrote: >> >> Any suggestions for the image drag command? >> > > Well, try to restore it to: > > img="$TM_DROPPED_FILE" > alt=`echo $img | perl -pe 's/^(.*\/)?(.*?)(\..*)?$/$2/g' | tr '_-' > ' '` > sips -g pixelWidth -g pixelHeight "$img" | awk '/pixelWidth/ { w= > $2 } /pixelHeight/ { h=$2 } END { printf(" width=\"%d\" height=\"%d\" alt=\"${0:'"$alt"'}\" />", w, h) }' > > If this fails, try one thing at a time, e.g. just: > sips -g pixelWidth -g pixelHeight "$TM_DROPPED_FILE" > > Btw: if you have an IRC client, msg me on #textmate / FreeNode, > that's a bit easier than this... > > ______________________________________________________________________ > For new threads USE THIS: textmate(a)lists.macromates.com > (threading gets destroyed and the universe will collapse if you don't) > http://lists.macromates.com/mailman/listinfo/textmate > --===============8542482094838709414==-- From skiadas@math.uchicago.edu Wed May 25 20:19:13 2005 From: Charilaos Skiadas To: textmate@lists.macromates.com Subject: Re: [TxMt] & drag commands Date: Wed, 25 May 2005 15:19:10 -0500 Message-ID: In-Reply-To: <17D59CE5-5C7A-4B12-AC68-582F9A2426D1@ideacog.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2500844591332175729==" --===============2500844591332175729== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On May 25, 2005, at 2:53 PM, Ben Parzybok wrote: > Hi, I'm reviving this somewhat old thread on dragging images (and css) > into an open html file. > I'm unable to get an tag when I try to drag an image into an > open html file, I get only the very long binary write-out. I just tried it, and it works fine for me. Are you sure the image you are dragging has one of the extensions that are handled by the drag? I renamed the extension of a jpg image to jpe, and it got loaded as binary data instead, but when its extension was jpg, it worked as expected. Also, if the spelling was Jpg, then it was not recognized either. Also, are you certain the language for the file is html? > > I have: > img=$TM_DROPPED_FILE > alt=`echo $img | perl -pe 's/^(.*\/)?(.*?)(\..*)?$/$2/g' | tr '_-' ' '` > echo -n "![\${1:$alt}]($TM_DROPPED_FILE)" This is what I have: img="$TM_DROPPED_FILE" alt=`perl <<<$img -pe 's/^(.*\/)?(.*?)(\..*)?$/$2/g; y/_-/ /'` sips -g pixelWidth -g pixelHeight "$img" | awk '/pixelWidth/ { w=$2 } /pixelHeight/ { h=$2 } END { printf("\"${0:'"$alt"'}\"", w, h) }' > as the Drag command in the bundle editor. > (under Markdown/Insert tag) > Applying to these file types: > png, PNG, jpeg, JPEG, jpg, JPG, gif, GIF So, unless your file has as extension EXACTLY one of those, it will not work. > --OK, I just listed only drag commands and found there was also a > Latex img drag command. > I've tried removing the latex bundle, restarting, trying the drag > command. > Then replacing latex, removing markdown bundle and trying drag > command. Still no go. This should not affect things, the latex drag command should work only if the language is latex. > Does anyone have any suggestions? > > Thanks in advance, > Ben Haris --===============2500844591332175729==-- From info@ideacog.net Wed May 25 20:44:22 2005 From: Ben Parzybok To: textmate@lists.macromates.com Subject: Re: [TxMt] & drag commands Date: Wed, 25 May 2005 13:44:13 -0700 Message-ID: <42A9ED73-30C9-42B9-A501-24A77B68AA27@ideacog.net> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8414577317534502948==" --===============8414577317534502948== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Hi Haris, Thanks for your reply. > I just tried it, and it works fine for me. Are you sure the image > you are dragging has one of the extensions that are handled by the > drag? I renamed the extension of a jpg image to jpe, and it got > loaded as binary data instead, but when its extension was jpg, it > worked as expected. Also, if the spelling was Jpg, then it was not > recognized either. > Also, are you certain the language for the file is html? My file extensions are correct, i've tried .png, .jpg and .gif with the same results. However I did have the language set to PHP. Trying HTML (PHP) resulted in the same binary output. Interestingly the drag command does work for href links. OK, I just duplicated my drag command and re-entered the code for the img drag command img="$TM_DROPPED_FILE" alt=`perl <<<$img -pe 's/^(.*\/)?(.*?)(\..*)?$/$2/g; y/_-/ /'` sips -g pixelWidth -g pixelHeight "$img" | awk '/pixelWidth/ { w= $2 } /pixelHeight/ { h=$2 } END { printf("\"${0:'"$alt"'}\"", w, h) }' and reset the file extensions and it worked. The one thing that was different was the scope field, which I guess I don't understand yet. It used to be: text.html.markdown and now it's just: text.html Also I should note that the drag command that's working is now under the HTML heading (because I duplicated the drag command that was there) and not under the Markdown heading in the bundle editor. -Ben --===============8414577317534502948==-- From allan@macromates.com Wed May 25 23:38:10 2005 From: Allan Odgaard To: textmate@lists.macromates.com Subject: Scope (was: [TxMt] & drag commands) Date: Thu, 26 May 2005 01:37:58 +0200 Message-ID: <40F041C8-8133-4954-A8BC-D38DB5D79FB8@macromates.com> In-Reply-To: <42A9ED73-30C9-42B9-A501-24A77B68AA27@ideacog.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2668413948517469118==" --===============2668413948517469118== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit On May 25, 2005, at 22:44, Ben Parzybok wrote: > The one thing that was different was the scope field, which I guess > I don't understand yet. The scope is where the command should be active (i.e. the language). If you have enabled the Language Definition bundle then try e.g. to place the caret on a string in PHP in HTML, then press ctrl-shift-T (a command that shows the current scope as a tooltip), it should show: text.html.basic source.php.embedded.html string.double-quoted.php This is the scope that the caret is in, and you can limit settings, styles, and bundle items to work only for a given scope. So scopes are very much like CSS selectors -- also, when you enter the scope, TextMate performs pattern matching, so you don't have to enter all of it, e.g. you could just enter: “string” and the (in this case) drag command would only be used, when you drag stuff onto strings. For something like a drag command you'd just set the first part of the scope, i.e. text.html versus text.latex or source.css. This btw means that if you have in a HTML file, dragging stuff to that section will get the appropriate drag command scoped to source.css, where dragging to outside this section will result in the commands scoped to text.html. There should be coverage of this in the release notes (for 1.1b6). --===============2668413948517469118==-- From info@ideacog.net Thu May 26 01:02:41 2005 From: Ben Parzybok To: textmate@lists.macromates.com Subject: Re: Scope (was: [TxMt] & drag commands) Date: Wed, 25 May 2005 17:40:46 -0700 Message-ID: <6ACB636B-EB7C-4EA9-894C-9248BE394A5D@ideacog.net> In-Reply-To: <40F041C8-8133-4954-A8BC-D38DB5D79FB8@macromates.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5129901238738567330==" --===============5129901238738567330== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit > On May 25, 2005, at 4:37 PM, Allan Odgaard wrote: > So scopes are very much like CSS selectors -- also, when you enter > the scope, TextMate performs pattern matching, so you don't have to > enter all of it, e.g. you could just enter: “string” and the (in > this case) drag command would only be used, when you drag stuff > onto strings. Very cool, I'm finally beginning to understand what's been happening b5 - b9 -- Thanks Alan. -b --===============5129901238738567330==--