TextEdit long delay for .sh

Hello.

I allways open textedit with plain text, and the I just change when I need rich text, command shift T.

Talking about open souce and such, one of the funniest things to play with is sketch, which is Apples demo program for scriptability. You can actually script diagrams with it. :slight_smile:

Well, it should work with plain text now, there are several backup schemes for the save handler, you have overwrite, save the previous version to a new name with supplied extension, or save the file with the next higher number.

The properties are set on the docs, so, whatever extension you choose, they should open by default in TextEdit.

Thanks.

Hi DJ,

Thatā€™s right. I forgot about the open source TextEdit example. Iā€™ll look into it. I Hope itā€™s in AppleScript ObjC.

Hi McUsr,

That Command + Shift + T works very well with a new document. Didnā€™t think of that. Iā€™ve seen the Sketch example also. And I was thinking about making a simple text editor from scratch! :smiley:

One thing I was thinking about was AXRaise. Iā€™m quite sure that in os10.8 AXRaise only brought the front window frontmost and not any others from that app. Here in os10.9 it brings every window above those of other apps.

Thanks for the info,
kel

Hello.

I proclaim I can make the AXRaise work precisely as I want it to, in just bringing the first window to front, (at least until Iā€™m proven wrong :smiley: ).

Edit AXRaise works perfectly if you use system events, to address the application process TextEdit, which then must address the window, by its index before performing action ā€œAXRaiseā€

Hello.

You can make your own editor in Xcode in 10 seconds, you create a cocoa project based on the ā€œdocument basedā€ template, and compile it. :slight_smile:

One thing Iā€™ve wanted to do a lot lately was making the table. So, just for fun I got this. With a blank rtf document in front:

set t to linefeed & "a	b	c	d
e	f	g	h
i	j	k	l" & linefeed
--
tell application "TextEdit"
	launch
	activate
	set text of front document to t
end tell
tell application "System Events"
	tell process "TextEdit"
		key code 123
		key code 123 using {command down, shift down}
		key code 123 using shift down
		key code 123 using {command down, shift down}
		key code 123 using shift down
		key code 123 using {command down, shift down}
		tell menu bar 1
			tell menu bar item "Format"
				tell menu "Format"
					tell menu item "Table."
						perform action "AXPress"
					end tell
				end tell
			end tell
		end tell
	end tell
end tell

This is the English version. Iā€™m not very good at making it international.

In Xcode the thing that takes a lot of time is reading through the documents.

Hello.

Your script looks nice, Iā€™ll localize for my lingo and play with it. :slight_smile:

Another way, that requires less UI scritping is to generate html with the help of sed, Iā€™m not sure if you can make empty table cells, or have to fill them with something, but empty tables are fairly easy to make with TextEdit, and with Yvanā€™s and Nigelā€™s brilliant scripts (post #14 and #2) , you can pretty much UI Script anything that is localized.

Well, you can generate a table with sed,(embedded with html) open it in Safari, keystroke cmd - C, and then paste it into TextEdit, (Then you can even have coloured background , styled with help of css, when you generate the html with sed!

Well, I am off to fix the rest of the library.

Hi McUsr,

Now that you mention html, I think notes takes html or maybe even javascript.

Hello.

You can AppleScript Notes. I saw a service here the other day. :slight_smile:

Yes, it works in Notes! :smiley: Hereā€™s another rough script:

set the_html to "<html>
<head>

<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">
<title></title>
</head>
<body>
<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\" width=\"100%\">
<tbody>
<tr>
<td valign=\"top\">a<br>
</td>
<td valign=\"top\">b<br>
</td>
</tr>
<tr>
<td valign=\"top\">c<br>
</td>
<td valign=\"top\">d<br>
</td>
</tr>
</tbody>
</table>
<br>
</body>
</html>
"

tell application "Notes"
	activate
	set table_note to first note whose name is "Tables:"
	set body of table_note to the_html
end tell

I need to look into this too.

Hello.

That looks cool, Iā€™ll give it a try, I think Shane Stanley also posted a post, with a link to scripting Notes in Code Exchange a year ago or so. I think Regulus 6633 participated, if that can help you to reveal the thread. (If memory serves right then the thread was Reguluā€™s, but I donā€™t bet on it.)

Edit

The Notes script worked fine, but the TextEdit script I couldnā€™t make to work perfectly, did all the characters in it go into a cell of their own for you?

Hi McUsr,

Yes, the ui scripting script works consistently on my computer. It first enters the tab delimited table data with linefeeds before and after. Then it selects the table data without the linefeeds at the ends. Then it selects the Tableā€¦ menu. The data shows in different fields. Itā€™s not good for the Library.

I like your html hint though. The modifiable table looks much better than the TextEdit table.

Iā€™ll search and see into those discussions that you mentioned. Also, I really want to look into the TextEdit open source.

Have a good day,
kel

Hello.

I have debugged the Output library the first time around, and the basic functionality seems to work, and I have written the docs, so I think Iā€™ll delete the posts concerning it in this thread in a short while, just so it is consistent. :slight_smile:

Have a good day you to Kel!

Hi McUsr,

Iā€™ll download the new updated library and check it out when I get back. :slight_smile:

Need to go to work now.:frowning:

Thanks for everything,
kel

Hello.

Youā€™ll find the finished library here and thank you for your participation! :slight_smile:

Wow, nice documentation! :smiley: It really helps.

Edited: btw, hereā€™s one last post on a work in progress about the tables:

script MakeNote
	property the_name : "Tables:"
	property the_body : "<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">
<title></title>
</head>
<body>
" & the_name & "<br>
<br>
</body>
</html>
"
	-- create the note
	tell application "Notes"
		launch
		activate
		make new note at folder "Notes" with properties {name:"Tables:", body:the_body}
	end tell
	run script my ConcatTable
	return result
end script

script ConcatTable
	property the_name : "Tables:"
	property the_body : "<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">
<title></title>
</head>
<body>
<br>
Table x<br>
<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\" width=\"100%\">
<tbody>
<tr>
<td valign=\"top\">a<br>
</td>
<td valign=\"top\">b<br>
</td>
</tr>
<tr>
<td valign=\"top\">c<br>
</td>
<td valign=\"top\">d<br>
</td>
</tr>
</tbody>
</table>
<br>
</body>
</html>
"
	tell application "Notes"
		launch
		activate
		set the_note to first note whose name is the_name
		set new_body to (body of the_note) & the_body
		set body of the_note to new_body
	end tell
	return it
end script

property the_script : MakeNote

set the_script to (run script the_script)

After the first run, It adds tables. Need to work on table names, number of table rows and columns, and table content, and maybe other stuff.

Have a good day, :slight_smile:
kel

Hello.

Thank you for your kind words, and for your updated script.

I am going to play with the notes app script, some, as I am really fond of notes: it is a really versatile little application.

Have a good day you too Kel!

Thatā€™s what I was saying. The computer is filled with new toys. :smiley:

Edited: I skipped over from Jaguar (10.2.8). :lol:

Hi DJ,

BTW, the sample code for TextEdit is updated for os10.9.

Edited: another big thing the Notes table script needs working on is if the user deletes the note. Iā€™m thinking that I might need to make a folder.

Edited: that sounds good because you can more easily search for a table.

Have a good day,
kel