<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: editor code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 12 Oct 2008 19:48:29 GMT</pubDate>
    <description>DZone Snippets: editor code</description>
    <item>
      <title>Change Ubuntu's default text editor</title>
      <link>http://snippets.dzone.com/posts/show/6012</link>
      <description>Tired with using nano as the default text editor in Ubuntu? To change the text editor permanently to vi type the following command from the command line.&lt;br /&gt;&lt;code&gt;sudo update-alternatives --config editor&lt;/code&gt;</description>
      <pubDate>Tue, 02 Sep 2008 15:40:32 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/6012</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>handling/configuring event when tinymce editor initializes</title>
      <link>http://snippets.dzone.com/posts/show/5769</link>
      <description>Initialize the editor the traditional way&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;tinyMCE.init({&lt;br /&gt;   ...&lt;br /&gt;   setup : function(ed) {&lt;br /&gt;      ed.onInit.add(window.testfunc);&lt;br /&gt;      &lt;br /&gt;   }&lt;br /&gt;});&lt;br /&gt;&lt;br /&gt;function testfunc()&lt;br /&gt;{&lt;br /&gt;   alert('Editor initialized');&lt;br /&gt;&lt;br /&gt;   //set content for editor &lt;br /&gt;   var ed = tinyMCE.get('editor');&lt;br /&gt;   ed.setContent(hfContent.value);//setting value from hidden field	&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 15 Jul 2008 06:57:32 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5769</guid>
      <author>deostroll (Arun Jayapal)</author>
    </item>
    <item>
      <title>setting tinymce editor content via javascript</title>
      <link>http://snippets.dzone.com/posts/show/5768</link>
      <description>setting tinymce editor content via javascript&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;    tinyMCE.get(mceId).execCommand('mceSetContent',false, '&lt;p&gt;some text&lt;table&gt;&lt;/table&gt;&lt;/p&gt;' );&lt;br /&gt;&lt;/script&gt;     &lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 15 Jul 2008 06:07:44 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5768</guid>
      <author>deostroll (Arun Jayapal)</author>
    </item>
    <item>
      <title>A solution for the "Graphical Editor" problem</title>
      <link>http://snippets.dzone.com/posts/show/5245</link>
      <description>A solution for the "Graphical Editor" problem.&lt;br /&gt; &lt;br /&gt;Problem description:&lt;br /&gt;&lt;a href="http://icpcres.ecs.baylor.edu/onlinejudge/external/102/10267.html"&gt;http://icpcres.ecs.baylor.edu/onlinejudge/external/102/10267.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Author: &lt;a href="http://joanatrindade.wikidot.com"&gt;Joana Matos Fonseca da Trindade&lt;/a&gt;&lt;br /&gt;Date: 2008.03.12&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;/* &lt;br /&gt; * Solution for the "Graphical Editor" problem.&lt;br /&gt; * UVa ID: 10267&lt;br /&gt; */&lt;br /&gt;#include &lt;stdio.h&gt;&lt;br /&gt;&lt;br /&gt;#define MAX 250&lt;br /&gt;#define OFFSET 1&lt;br /&gt;#define DOS_NAME 12&lt;br /&gt;&lt;br /&gt;/* global image bounds */&lt;br /&gt;int n, m;&lt;br /&gt;&lt;br /&gt;/* fills a rectangle with the specified color */&lt;br /&gt;int fillRectangle(int m_ini, int n_ini, int m_end, int n_end, char color, char pTable[][MAX+OFFSET]) {&lt;br /&gt;	int i, j;&lt;br /&gt;	for (i = n_ini; i &lt;= n_end; i++) {&lt;br /&gt;		for (j = m_ini; j &lt;= m_end; j++) {&lt;br /&gt;			pTable[i][j] = color;&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;	return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* fills a region R with the specified color */&lt;br /&gt;int fillRegion(int x, int y, char oldColor, char newColor, char pTable[][MAX+OFFSET]) {	&lt;br /&gt;	/* (x,y) is in region R */&lt;br /&gt;	pTable[y][x] = newColor;&lt;br /&gt;	&lt;br /&gt;	/* recursively check all 4 directions for neighbours of (x,y) with same color */&lt;br /&gt;	if ((pTable[y][x-1] == oldColor) &amp;&amp; (x &gt; OFFSET)) {         &lt;br /&gt;		fillRegion(x-1, y, oldColor, newColor, pTable);&lt;br /&gt;	}&lt;br /&gt;	if ((pTable[y][x+1] == oldColor) &amp;&amp; (x &lt; m)) {       &lt;br /&gt;		fillRegion(x+1, y, oldColor, newColor, pTable);&lt;br /&gt;	}&lt;br /&gt;	if ((pTable[y-1][x] == oldColor) &amp;&amp; (y &gt; OFFSET)) {        &lt;br /&gt;		fillRegion(x, y-1, oldColor, newColor, pTable);&lt;br /&gt;	}&lt;br /&gt;	if ((pTable[y+1][x] == oldColor) &amp;&amp; (y &lt; n)) {        &lt;br /&gt;		fillRegion(x, y+1, oldColor, newColor, pTable);&lt;br /&gt;	}&lt;br /&gt;	return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* outputs the image */&lt;br /&gt;int printImage(int m, int n, char pTable[][MAX+OFFSET]) {&lt;br /&gt;	int i, j;	&lt;br /&gt;	for (i = OFFSET; i &lt; n+OFFSET; i++) {&lt;br /&gt;		for (j = OFFSET; j &lt; m+OFFSET; j++ ) {&lt;br /&gt;			printf("%c", pTable[i][j]);&lt;br /&gt;		}&lt;br /&gt;		printf("\n");&lt;br /&gt;	}&lt;br /&gt;	return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* main */&lt;br /&gt;int main (int argc, const char * argv[]) {&lt;br /&gt;	/* the image */&lt;br /&gt;	char image[MAX+OFFSET][MAX+OFFSET];&lt;br /&gt;&lt;br /&gt;	/* editor command */&lt;br /&gt;	char command;&lt;br /&gt;	&lt;br /&gt;	/* coords */&lt;br /&gt;	int x1, x2, y1, y2, tmp;&lt;br /&gt;	&lt;br /&gt;	/* colors */&lt;br /&gt;	char color, oldColor;&lt;br /&gt;	&lt;br /&gt;	/* filename */&lt;br /&gt;	char filename[DOS_NAME+1];&lt;br /&gt;			&lt;br /&gt;	while(scanf("%c", &amp;command) != EOF) {		&lt;br /&gt;		/* X, terminates the session */&lt;br /&gt;		if (command == 'X') {&lt;br /&gt;			return 0;&lt;br /&gt;		}		&lt;br /&gt;		switch (command) {&lt;br /&gt;			/* create image */&lt;br /&gt;			case 'I' :&lt;br /&gt;				scanf("%d %d", &amp;m, &amp;n);&lt;br /&gt;				fillRectangle(1, 1, m, n, 'O', image);&lt;br /&gt;				break;&lt;br /&gt;			&lt;br /&gt;			/* clear image */&lt;br /&gt;			case 'C' :&lt;br /&gt;				fillRectangle(1, 1, m, n, 'O', image);&lt;br /&gt;				break;&lt;br /&gt;			&lt;br /&gt;			/* colors a pixel */&lt;br /&gt;			case 'L' :&lt;br /&gt;				scanf("%d %d %c", &amp;x1, &amp;y1, &amp;color);&lt;br /&gt;				image[y1][x1] = color;&lt;br /&gt;				break;&lt;br /&gt;			&lt;br /&gt;			/* draw vertical segment */&lt;br /&gt;			case 'V' :&lt;br /&gt;				scanf("%d %d %d %c", &amp;x1, &amp;y1, &amp;y2, &amp;color);&lt;br /&gt;				if (y2 &gt;= y1)&lt;br /&gt;					fillRectangle(x1, y1, x1, y2, color, image);&lt;br /&gt;				else&lt;br /&gt;					fillRectangle(x1, y2, x1, y1, color, image);&lt;br /&gt;				break;&lt;br /&gt;			&lt;br /&gt;			/* draw horizontal segment */&lt;br /&gt;			case 'H' : &lt;br /&gt;				scanf("%d %d %d %c", &amp;x1, &amp;x2, &amp;y1, &amp;color);&lt;br /&gt;				if (x2 &gt;= x1)&lt;br /&gt;					fillRectangle(x1, y1, x2, y1, color, image);&lt;br /&gt;				else&lt;br /&gt;					fillRectangle(x2, y1, x1, y1, color, image);&lt;br /&gt;				break;&lt;br /&gt;			&lt;br /&gt;			/* draw rectangle */&lt;br /&gt;			case 'K' : &lt;br /&gt;				scanf("%d %d %d %d %c", &amp;x1, &amp;y1, &amp;x2, &amp;y2, &amp;color);&lt;br /&gt;				if (x1 &gt;= x2) {&lt;br /&gt;					tmp = x1;&lt;br /&gt;					x1 = x2;&lt;br /&gt;					x2 = tmp;&lt;br /&gt;				}&lt;br /&gt;				if (y1 &gt;= y2) {&lt;br /&gt;					tmp = y1;&lt;br /&gt;					y1 = y2;&lt;br /&gt;					y2 = tmp;&lt;br /&gt;				}&lt;br /&gt;				fillRectangle(x1, y1, x2, y2, color, image);&lt;br /&gt;				break;&lt;br /&gt;			&lt;br /&gt;			/* fill */&lt;br /&gt;			case 'F' :&lt;br /&gt;				scanf("%d %d %c", &amp;x1, &amp;y1, &amp;color);&lt;br /&gt;				oldColor = image[y1][x1];&lt;br /&gt;				if (oldColor != color) {&lt;br /&gt;					fillRegion(x1, y1, oldColor, color, image);&lt;br /&gt;				}&lt;br /&gt;				break;&lt;br /&gt;&lt;br /&gt;			/* fill */&lt;br /&gt;			case 'S' :&lt;br /&gt;				scanf("%s", &amp;filename);&lt;br /&gt;				printf("%s\n", filename);&lt;br /&gt;				printImage(m, n, image);&lt;br /&gt;				break;			&lt;br /&gt;		&lt;br /&gt;			default: &lt;br /&gt;				break;&lt;br /&gt;		}		&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 18 Mar 2008 09:23:41 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5245</guid>
      <author>jmftrindade (Joana M. F. da Trindade)</author>
    </item>
    <item>
      <title>SciTE, my "good default options"</title>
      <link>http://snippets.dzone.com/posts/show/694</link>
      <description>They should be default options of SciTE (good for python too)&lt;br /&gt;just put them in your scite user properties (menu &gt; options &gt; open user properties) &lt;br /&gt;&lt;code&gt;&lt;br /&gt;# visual options of the gui&lt;br /&gt;tabbar.hide.one=0&lt;br /&gt;toolbar.visible=1&lt;br /&gt;tabbar.visible=1&lt;br /&gt;statusbar.visible=1&lt;br /&gt;line.margin.visible=1&lt;br /&gt;line.margin.width=4&lt;br /&gt;buffers=20&lt;br /&gt;buffers.zorder.switching=1&lt;br /&gt;&lt;br /&gt;# editing options&lt;br /&gt;braces.check=1&lt;br /&gt;braces.sloppy=1&lt;br /&gt;are.you.sure=1&lt;br /&gt;load.on.activate=1&lt;br /&gt;are.you.sure.on.reload=1&lt;br /&gt;reload.preserves.undo=1&lt;br /&gt;&lt;br /&gt;# source-respect options&lt;br /&gt;strip.trailing.spaces=1&lt;br /&gt;tabsize=4&lt;br /&gt;indent.size=4&lt;br /&gt;use.tabs=0&lt;br /&gt;indent.auto=1&lt;br /&gt;indent.opening=1&lt;br /&gt;indent.closing=1&lt;br /&gt;tab.indents=1&lt;br /&gt;backspace.unindents=1&lt;br /&gt;eol.mode=LF&lt;br /&gt;eol.auto=1&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 09 Sep 2005 22:59:14 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/694</guid>
      <author>manatlan (manatlan)</author>
    </item>
    <item>
      <title>wierd little online text editor</title>
      <link>http://snippets.dzone.com/posts/show/235</link>
      <description>careful who gets access to this script. as far as i can tell this can only modify files in its own directory (although i didn't explicitly make it that way). im new at perl so careful anyway. questions or comments? (dj_bidi@fastmail.fm)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;&lt;br /&gt;##         SLEd (Sort Of Like Ed) Editor&lt;br /&gt;## USE:&lt;br /&gt;##  append commands to url after a question mark &lt;br /&gt;## COMMANDS:&lt;br /&gt;##  open (temp) file:                      -f,[file_to_edit]&lt;br /&gt;##  close (temp)file:                      -d &lt;br /&gt;##  delete real file (careful!):           -dd&lt;br /&gt;##  insert line (0 inserts at beginning):  -[line_number]a,[new_text] &lt;br /&gt;##  replace line:                          -[line_number],[new_text]&lt;br /&gt;##  regex replace in line (like s///g):    -[line_number],/[old]/[new]/&lt;br /&gt;##  add line:                              [line_to_add]&lt;br /&gt;##  delete line:                           -[line_number]&lt;br /&gt;##  save over real file:                   . &lt;br /&gt;##  save as new file:                      .[newfile_name]&lt;br /&gt;## QUIRKS:&lt;br /&gt;##  use ":lb:" to pass a #&lt;br /&gt;&lt;br /&gt;$in = $ENV{'QUERY_STRING'};&lt;br /&gt;$in =~ s/%3C/&lt;/g;&lt;br /&gt;$in =~ s/%3E/&gt;/g;&lt;br /&gt;$in =~ s/:lb:/#/g;&lt;br /&gt;$in =~ s/%20/ /g;&lt;br /&gt;$in =~ s/%22/"/g;&lt;br /&gt;&lt;br /&gt;$url = $ENV{'SCRIPT_URI'};&lt;br /&gt;($name = $url) =~ s/.+\///;&lt;br /&gt;$file = "~SLEd.pl";&lt;br /&gt;&lt;br /&gt;if ($in =~ /-f,(.*)/) {&lt;br /&gt; if ($file ne "") {&lt;br /&gt;  unlink "$file";&lt;br /&gt; }&lt;br /&gt; $new = $1;&lt;br /&gt; $new =~ s/;//g;&lt;br /&gt; $new =~ s/"//g;&lt;br /&gt; open (IN, "$new");&lt;br /&gt; if (length($new) != 0) { &lt;br /&gt;  open (OUT, "&gt;~$new");&lt;br /&gt; }&lt;br /&gt; while ($_ = &lt;IN&gt;) {&lt;br /&gt;  print OUT "$_";&lt;br /&gt; }&lt;br /&gt; close IN;&lt;br /&gt; close OUT;&lt;br /&gt; rename "$name", "~bak";&lt;br /&gt; open (IN, "~bak");&lt;br /&gt; open (OUT, "&gt;$name");&lt;br /&gt; while ($_ = &lt;IN&gt;) {&lt;br /&gt;  if (length($new) == 0) {&lt;br /&gt;   $_ =~ s/\$file = \".*\"/\$file = \"\"/g;&lt;br /&gt;  } else {&lt;br /&gt;   $_ =~ s/\$file = \".*\"/\$file = \"~$new\"/g;&lt;br /&gt;  } &lt;br /&gt;  print OUT "$_";&lt;br /&gt; }&lt;br /&gt; close IN;&lt;br /&gt; close OUT;&lt;br /&gt; unlink "~bak";&lt;br /&gt; print "location: $url\n\n";&lt;br /&gt; die;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if ($in  eq ".") {&lt;br /&gt; ($f = $file) =~ s/^~//;&lt;br /&gt; unlink "$f";&lt;br /&gt; rename("$file", "$f");&lt;br /&gt; print "location: $url?-f,\n\n";&lt;br /&gt; die;&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;if ($in eq "-dd") {&lt;br /&gt; ($f = $file) =~ s/^~//;&lt;br /&gt; unlink "$f";&lt;br /&gt; unlink "$file";&lt;br /&gt; print "location: $url?-f,\n\n";&lt;br /&gt; die;&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;if ($in =~ /^\.(.+)/) {&lt;br /&gt; $new = $1;&lt;br /&gt; $new =~ s/;//g;&lt;br /&gt; $new =~ s/"//g;&lt;br /&gt; ($f = $file) =~ s/^~//;&lt;br /&gt; rename("$file", "$new");&lt;br /&gt; print "location: $url?-f,\n\n";&lt;br /&gt; die;&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;if ($in eq "-d") {&lt;br /&gt; unlink "$file";&lt;br /&gt; print "location: $url?-f,\n\n";&lt;br /&gt; die;&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;if ($in =~ /^-([0-9]+)a,(.+)/) {&lt;br /&gt;  $i = 1;&lt;br /&gt;  if ($1 == 0) {&lt;br /&gt;   push(@print, "$2\n");&lt;br /&gt;  }&lt;br /&gt;  open (F, "$file");&lt;br /&gt;  while (&lt;F&gt;) {&lt;br /&gt;   if ($i != $1) {&lt;br /&gt;    push(@print, $_);&lt;br /&gt;   } else {&lt;br /&gt;    push(@print, $_);&lt;br /&gt;    push(@print, "$2\n");&lt;br /&gt;   }&lt;br /&gt;   $i++;&lt;br /&gt;  }&lt;br /&gt;  close F; &lt;br /&gt;  open (F, "&gt;$file");&lt;br /&gt;  foreach $line(@print) {&lt;br /&gt;   print F "$line";&lt;br /&gt;  }&lt;br /&gt;  close F;&lt;br /&gt;  print "location: $url\n\n";&lt;br /&gt;&lt;br /&gt;} elsif ($in =~ /^-([0-9]+),(.+)/) {&lt;br /&gt;  $lino = $1;&lt;br /&gt;  $replace = $2;&lt;br /&gt;  $i = 1;&lt;br /&gt;  open (F, "$file");&lt;br /&gt;  while (&lt;F&gt;) {&lt;br /&gt;   if ($i != $lino) {&lt;br /&gt;    push(@print, $_);&lt;br /&gt;   } elsif ($replace =~ m/^\/(.+?)\/(.*)\/$/) {&lt;br /&gt;    $ol = $1;&lt;br /&gt;    $newe = $2;&lt;br /&gt;    ($match = $_) =~ s/$ol/$newe/g;&lt;br /&gt;    push(@print, $match);&lt;br /&gt;   } else {&lt;br /&gt;    push(@print, "$replace\n");&lt;br /&gt;   }&lt;br /&gt;   $i++;&lt;br /&gt;  }&lt;br /&gt;  close F;  &lt;br /&gt;  open (F, "&gt;$file");&lt;br /&gt;  foreach $line(@print) {&lt;br /&gt;   print F "$line";&lt;br /&gt;  }&lt;br /&gt;  close F;&lt;br /&gt;  print "location: $url\n\n";&lt;br /&gt;&lt;br /&gt;} elsif ($in =~ /^-([0-9]+)$/) {&lt;br /&gt; $i = 1;&lt;br /&gt; open (F, "$file");&lt;br /&gt; while (&lt;F&gt;) {&lt;br /&gt;  if ($i != $1) {&lt;br /&gt;   push(@print, $_);&lt;br /&gt;  }&lt;br /&gt;  $i++;&lt;br /&gt; }&lt;br /&gt; close F;&lt;br /&gt; open (F, "&gt;$file");&lt;br /&gt; foreach $line(@print) {&lt;br /&gt;  print F "$line";&lt;br /&gt; }&lt;br /&gt; close F;&lt;br /&gt; print "location: $url\n\n";&lt;br /&gt;&lt;br /&gt;} elsif ($in) {&lt;br /&gt; open (F, "&gt;&gt;$file");&lt;br /&gt; print F "$in\n";&lt;br /&gt; close F;&lt;br /&gt; print "location: $url\n\n";&lt;br /&gt;&lt;br /&gt;} else {&lt;br /&gt; print "Content-type: text/plain\n\n";&lt;br /&gt; open (F, "$file");&lt;br /&gt; $i = 1;&lt;br /&gt; while (&lt;F&gt;) {&lt;br /&gt;  print "[$i] $_";&lt;br /&gt;  $i++;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 29 Apr 2005 01:12:43 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/235</guid>
      <author>31d1 (srirupa deadwyler)</author>
    </item>
  </channel>
</rss>
