Re: How to get Balance Tags to include the tags
OK, with help from Roland Küffner and Christopher Stone, I've been able to create the script I need. More on that in a bit. There have been a number of suggestions that using find/replace with grep should work. That only works well if there are no nested spans (with inner spans that I want to keep ... i.e. spans with class attributes as opposed to span elements with no attributes). And matching beginning and closing tags is difficult in a nested element scenario. So, a script seems like the safest approach. So here is what I did. First, I started with the script from Roland that selected the outer tags of a balanced tag selection. I'll repeat that original script here: tell application BBEdit if (balance tags) then set x to characterOffset of selection set y to x + (length of selection) inside tag start range (x - 2) end range (x - 2) set tagLength to (end_offset of tag of result) - (start_offset of tag of result) set x to x - tagLength - 1 inside tag start range (y + 1) end range (y + 1) set tagLength to (end_offset of tag of result) - (start_offset of tag of result) set y to y + tagLength select characters x thru y of window 1 else beep -- script beeps if it could not create an initial balance end if end tell Then I modified it to remove the outer tags: tell application BBEdit if (balance tags) then set x to characterOffset of selection set y to x + (length of selection) inside tag start range (x - 2) end range (x - 2) set tagLength to (end_offset of tag of result) - (start_offset of tag of result) set xOpen to x - tagLength - 1 set lenOpen to tagLength set yOpen to xOpen + lenOpen inside tag start range (y + 1) end range (y + 1) set tagLength to (end_offset of tag of result) - (start_offset of tag of result) set xClose to y set lenClose to tagLength set yClose to xClose + lenClose -- set insertion point before character xClose tell window 1 to select (characters xClose thru yClose) tell window 1 to delete selection tell window 1 to select (characters xOpen thru yOpen) tell window 1 to delete selection else beep -- script beeps if it could not create an initial balance end if end tell Then I made it specific to a span element: tell application BBEdit set origInsPt to characterOffset of selection if (balance tags) then set x to characterOffset of selection set y to x + (length of selection) inside tag start range (x - 2) end range (x - 2) set t to tag of result if (span is equal to name of t) then set tagLength to (end_offset of t) - (start_offset of t) set xOpen to x - tagLength - 1 set lenOpen to tagLength set yOpen to xOpen + lenOpen inside tag start range (y + 1) end range (y + 1) set tagLength to (end_offset of tag of result) - (start_offset of tag of result) set xClose to y set lenClose to tagLength set yClose to xClose + lenClose -- set insertion point before character xClose tell window 1 to select (characters xClose thru yClose) tell window 1 to delete selection tell window 1 to select (characters xOpen thru yOpen) tell window 1 to delete selection else tell window 1 to select (insertion point before character origInsPt) beep -- script beeps if it outer element is not span/ end if else beep -- script beeps if it could not create an initial balance end if end tell Then I used a script from Chris to create the wrapper code to find an empty span element and do some processing with it; I added a loop that repeated until there were no more empty span elements remaining: tell application BBEdit set keepGoing to true repeat while keepGoing = true tell text of window 1 set fndRsltStart to find span options ¬ {search mode:grep, case sensitive:false, starting at top:true} with selecting match end tell set keepGoing to found of fndRsltStart if keepGoing = true then set z to characterOffset of selection
Opening Files in Project Feature Suggestion
I've been reading this group for a while and played a bit more with the Open File by Name feature (the closest to what other editors provide). While it is definitely not on par with other solutions (Cmd +T in TextMate, PeepCode, etc.) it could be good enough if: 1. it would use some filters to ignore files and searching While using it with a versioned project, a search will also look under .svn or .git folders. This is very annoying as I'd never really want to look into those files. In case some advanced users would actually need to access those files, then there could be a checkbox to disable global filters. The set of global filters would probably have to include: - versioning files - temporary files - binary/compilation result files 2. in some next version, the open file by name would perform a fuzzy live search: having feedback when performing an operation is so present these days, that it looks odd that a desktop application is not able to provide any feedback until clicking OK. I hope you'll consider these features for the next versions of BBEdit. Alex:// -- You received this message because you are subscribed to the BBEdit Talk discussion group on Google Groups. To post to this group, send email to bbedit@googlegroups.com To unsubscribe from this group, send email to bbedit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/bbedit?hl=en If you have a feature request or would like to report a problem, please email supp...@barebones.com rather than posting to the group. Follow @bbedit on Twitter: http://www.twitter.com/bbedit
Re: Opening Files in Project Feature Suggestion
On Saturday, August 27, 2011, Alex Popescu a...@mypopescu.com wrote: I've been reading this group for a while and played a bit more with the Open File by Name feature (the closest to what other editors provide). While it is definitely not on par with other solutions (Cmd +T in TextMate, PeepCode, etc.) it could be good enough if: http://groups.google.com/group/bbedit/browse_thread/thread/2796149661ec56f3 R. -- Rich Siegel Bare Bones Software, Inc. sie...@barebones.com http://www.barebones.com/ Someday I'll look back on all this and laugh... until they sedate me. -- You received this message because you are subscribed to the BBEdit Talk discussion group on Google Groups. To post to this group, send email to bbedit@googlegroups.com To unsubscribe from this group, send email to bbedit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/bbedit?hl=en If you have a feature request or would like to report a problem, please email supp...@barebones.com rather than posting to the group. Follow @bbedit on Twitter: http://www.twitter.com/bbedit
Re: Assigning Keystroke to Scratchpad
Thanks Chris! I got it working almost immediately. Works perfectly. The only weird thing is that I have one project, and the Scratchpad integrated into the project doesn't jive with the generic Scratchpad I get with other files and by using the keystroke. Do projects have there own Scratchpad separate from a generic Scratchpad. I looked at the manual but saw nothing about this. Anyone have a clue? On Aug 26, 10:06 pm, Christopher Stone listmeis...@thestoneforge.com wrote: On Aug 26, 2011, at 11:42, gary wrote: Ahh, that's what I want, the ability to call it up even if it's not the front most app. I actually have a license for keyboard maestro. __ Hey Gary, Run this from an Applescript action in Keyboard Maestro. -- Best Regards, Chris __ tell application BBEdit try activate open scratchpad window on error errMsg number errNum set sep to == set e to sep return Error: errMsg return sep return ¬ Error Number: errNum return sep beep display dialog e end try end tell -- You received this message because you are subscribed to the BBEdit Talk discussion group on Google Groups. To post to this group, send email to bbedit@googlegroups.com To unsubscribe from this group, send email to bbedit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/bbedit?hl=en If you have a feature request or would like to report a problem, please email supp...@barebones.com rather than posting to the group. Follow @bbedit on Twitter: http://www.twitter.com/bbedit
Re: Assigning Keystroke to Scratchpad
Okay, after fumbling around here's what I've found out. I apologize if I'm stating the obvious but I've just started using bbedit and have never done anything with applescript. The Scratchpad file that is called up when I use Keyboard Maestro lives here: /library/application support/bbedit There is one strange thing about it. It doesn't show an extension, but info says it's a text file. I can see what I've written on it with quick view. However, if I click on it to open it the apple script editor opens it. I get an error that says a identifier can't go after this identifier. I have two projects, and when I click show package contents they both have a Scratchpad file inside. Each maintains it's own info. And unlike the global scratchpad in application support, they do show a .txt extension, and when clicked, are opened by bbedit. If I open either project scratchpad their name is scratchpad.txt. But when I open the global Scratchpad with my keyboard shortcut, it only says Scratchpad, without the .txt extension, in the title bar. Which, I assume, is because of what I mentioned earlier (though it's a text file it's set to open with the apple script editor). So to sum up, what I see is one scratchpad not attached to any project, and a scratchpad for each project I create. That's the only way it makes sense to me. Am I correct? And secondly, should I be concerned that the global Scratchpad in bbedit application support shows no extension, and is set to be opened with the apple script editor? I thought this might simply be because the file was created with an apple script, and I also thought I could just go to info and change what the file is associated with from the apple script editor to bbedit, but I thought I might screw something up. Sorry this is so long and for any confusion. gary On Aug 27, 3:22 pm, Christopher Stone listmeis...@thestoneforge.com wrote: Hey Gary, On Aug 27, 2011, at 14:33, gary wrote: Thanks Chris! I got it working almost immediately. Works perfectly. Good. The only weird thing is that I have one project, and the Scratchpad integrated into the project doesn't jive with the generic Scratchpad I get with other files and by using the keystroke. Do projects have there own Scratchpad separate from a generic Scratchpad. That IS weird. As far as I know you cannot open *the* Scratchpad in a project window. Is there a 'Last Saved' date and 'File Path' associated with the one in the project? Could *you* have create your own 'Scratchpad' file and associated it with the project? What happens if you Command-Click on the menu bar icon one the one in the project? -- Best Regards, Chris -- You received this message because you are subscribed to the BBEdit Talk discussion group on Google Groups. To post to this group, send email to bbedit@googlegroups.com To unsubscribe from this group, send email to bbedit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/bbedit?hl=en If you have a feature request or would like to report a problem, please email supp...@barebones.com rather than posting to the group. Follow @bbedit on Twitter: http://www.twitter.com/bbedit
CSS format preference
In 10.0.2 I can't seem to find the preferences for the CSS format options. Such as when a declaration contains only one attribute I could keep it to one line verses individual lines for the braces. While Im at it, is there a way to adjust the format for CSS or JS with the SourceFormat.profile? Thanks. -- You received this message because you are subscribed to the BBEdit Talk discussion group on Google Groups. To post to this group, send email to bbedit@googlegroups.com To unsubscribe from this group, send email to bbedit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/bbedit?hl=en If you have a feature request or would like to report a problem, please email supp...@barebones.com rather than posting to the group. Follow @bbedit on Twitter: http://www.twitter.com/bbedit
Re: Assigning Keystroke to Scratchpad
Chris, Thanks for all the info and help. The global Scratchpad is what I want. In fact, this works much better for me now that I realize each project has it's own Scratchpad. I'd rather keep them separate. If I have something on a global Scratchpad I want to use in a Project I'll just copy it over. The only thing I'm really curious about is why the document called up by the apple script doesn't have a .txt extension. But as long is doesn't cause problems I'll just ask no questions :) Again, thanks for your help and patience. I really do appreciate it. cheers, gary On Aug 27, 8:21 pm, Christopher Stone listmeis...@thestoneforge.com wrote: Hey Gary, Thanks for taking the time to suss this out. On Aug 27, 2011, at 18:15, gary wrote: The Scratchpad file that is called up when I use Keyboard Maestro lives here: /library/application support/bbedit Right. There lives the global Scratchpad file. There is one strange thing about it. It doesn't show an extension, but info says it's a text file. I can see what I've written on it with quick view. However, if I click on it to open it the apple script editor opens it. I get an error that says a identifier can't go after this identifier. Don't worry about that. It IS odd that it would be associated with the Applescript Editor on your machine rather than TextEdit but not terribly. You can change it in the Finder if you want to. The error is caused by the Applescript Editor trying to compile it into Applescript. I have two projects, and when I click show package contents they both have a Scratchpad file inside. Each maintains it's own info. And unlike the global scratchpad in application support, they do show a .txt extension, and when clicked, are opened by bbedit. Okay. I had noticed the 'Scratchpad' and 'Unix Worksheet' items associated with the project, but I never access them in the file pane and didn't realize they were part of the project rather than the global files. Learn something new and all that... And secondly, should I be concerned that the global Scratchpad in bbedit application support shows no extension, and is set to be opened with the apple script editor? No. I thought this might simply be because the file was created with an apple script The file is not created with Applescript. The script simply calls the global Scratchpad window. and I also thought I could just go to info and change what the file is associated with from the apple script editor to bbedit, but I thought I might screw something up. This should not cause any problems. -- From the BBEdit 10 Release Notes: ◦ There's a new command on the Window menu: Show Unix Worksheet. This will open a worksheet document that is application-wide, and backed by a worksheet file saved in your Application Support/BBEdit folder. Like the Scratchpad, changes here are saved automatically. There's also a Unix worksheet window application property available to the scripting interface. (* Repeated for the Scratchpad) -- ◦ Project windows grow a couple of new lists: ◦ Recently Used: Shows documents recently opened into this project's window. ◦ Scratchpad Worksheet: Every project document carries its own scratch pad and worksheet document. This is shared for all users of the project, so if you wish you can use the scratchpad to make notes for other users; or store handy commands in the worksheet. ◦ These can be collapsed or hidden, if desired. -- NOW - Back to your original issue: Are you wanting to open the GLOBAL Scratchpad or the one LOCAL to your project file? -- Best Regards, Chris -- You received this message because you are subscribed to the BBEdit Talk discussion group on Google Groups. To post to this group, send email to bbedit@googlegroups.com To unsubscribe from this group, send email to bbedit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/bbedit?hl=en If you have a feature request or would like to report a problem, please email supp...@barebones.com rather than posting to the group. Follow @bbedit on Twitter: http://www.twitter.com/bbedit