Snippet Manager

v1.8 now available!

  • (11 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »

157 Replies - 29828 Views - Last Post: 02 March 2009 - 11:13 AM

#11 abgorn   User is offline

  • sudo apt install brain -y
  • member icon

Reputation: 31
  • View blog
  • Posts: 1,423
  • Joined: 05-June 08

Re: Snippet Manager

Posted 25 August 2008 - 04:33 AM

Cool, it's a simple but good idea :D I like it very much! And it's written with .NET framwork?
Was This Post Helpful? 0
  • +
  • -

#12 gabehabe   User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1440
  • View blog
  • Posts: 11,025
  • Joined: 06-February 08

Re: Snippet Manager

Posted 25 August 2008 - 04:49 AM

Yep. I've been working with .NET since... Saturday! :o
So this is all new to me, but I'm getting there.

Here it is:
Again, kept to see development, but the newest is further down in this post.
Attached File  Snippet_Manager_0.7.6a.zip (7.5K)
Number of downloads: 92


There are a lot of changes, all for the better. It looks much neater now, there's an about option, all the previous options are under "File" and there's syntax highlighting on the word "test." (I know it's not the right word, but it's a start) :)

I need to fix some of the syntax highlighting, make it start from the beginning of the current line as opposed to the beginning of the text every time, which will hopefully reduce the flashing.

Again, feedback is welcomed :)

EDIT:
Here's the latest version. There's some basic C++ syntax highlighting going on, it doesn't highlight it when you load a file yet, but it does it as you type. It scans the text for the current line, so flashing is reduced.
Note that the cursor moves to the end if you type somewhere in the middle of the box at the moment. That's one of the next things that I'll fix :)
Attached File  Snippet_Manager_0.8.3a.zip (7.38K)
Number of downloads: 123
<edit> Newer version available here </edit>

Here's a screen shot of the syntax highlighting in action:
Attached Image

I think the next addition will be preprocessor stuff, which makes the whole line a certain colour if there's a '#' at the beginning of the line.
Also, I'll make that stuff bold too, to make it stand out more. :)
Was This Post Helpful? 0
  • +
  • -

#13 gabehabe   User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1440
  • View blog
  • Posts: 11,025
  • Joined: 06-February 08

Re: Snippet Manager

Posted 25 August 2008 - 07:57 AM

I think I'm getting the hang of this!

Check out the syntax highlighting:
http://www.dreamincode.net/forums/index.php?act=Attach&type=post&id=8114

Hooray!

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#14 gbertoli3   User is offline

  • DIC at Heart + Code
  • member icon

Reputation: 41
  • View blog
  • Posts: 1,166
  • Joined: 23-June 08

Re: Snippet Manager

Posted 25 August 2008 - 07:59 AM

Alright Good Job!
I'm looking forward to seeing the final result
Was This Post Helpful? 0
  • +
  • -

#15 gabehabe   User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1440
  • View blog
  • Posts: 11,025
  • Joined: 06-February 08

Re: Snippet Manager

Posted 25 August 2008 - 08:11 AM

Well, I'm getting there slowly but surely :)

Next up, I suppose it's quotes, so I can get something like
"This is all a single colour";

Was This Post Helpful? 0
  • +
  • -

#16 abgorn   User is offline

  • sudo apt install brain -y
  • member icon

Reputation: 31
  • View blog
  • Posts: 1,423
  • Joined: 05-June 08

Re: Snippet Manager

Posted 25 August 2008 - 08:31 AM

Horay!!! In the image there was spacing. Did you type that yourself or is automatic in it?
Was This Post Helpful? 0
  • +
  • -

#17 gabehabe   User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1440
  • View blog
  • Posts: 11,025
  • Joined: 06-February 08

Re: Snippet Manager

Posted 25 August 2008 - 08:49 AM

I typed it myself, but I'm gonna work with that next :)
Was This Post Helpful? 0
  • +
  • -

#18 gabehabe   User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1440
  • View blog
  • Posts: 11,025
  • Joined: 06-February 08

Re: Snippet Manager

Posted 25 August 2008 - 10:40 AM

Got another update!

abgorn, this is just for you. Indentation!

It might need a bit of work, but it's certainly there.

This is how it looks:
http://www.dreamincode.net/forums/index.php?act=Attach&type=post&id=8116

I didn't indent any of it myself, that was all done automatically.

I think it's time to share some code, as a sneak preview:
		void indent ()
		{
			try
			{
				if (code.Text[code.Selectionstart-2] == '{' && code.Text[code.Selectionstart-1] == '\n')
				{
					tabs++;
					for (int i = 0; i < tabs; i++)
						code.AppendText ("   ");
				}				
				if (code.Text[code.Selectionstart-2] == '}' && code.Text[code.Selectionstart-1] == '\n')
				{
					code.Selectionstart -= 5;
					SendKeys.Send("{DELETE}{DELETE}{DELETE}{RIGHT}{RIGHT}");
					tabs--;
				}
						
				if (code.Text[code.Selectionstart-2] != '{' && code.Text[code.Selectionstart-1] == '\n')
					for (int i = 0; i < tabs; i++)
					code.AppendText ("   ");
					
			} catch (System.Exception t) {}
		}


I'll upload the latest version with indentation in a minute, I just gotta compress it.

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#19 abgorn   User is offline

  • sudo apt install brain -y
  • member icon

Reputation: 31
  • View blog
  • Posts: 1,423
  • Joined: 05-June 08

Re: Snippet Manager

Posted 25 August 2008 - 10:53 AM

Thanks for the snippet, I plan to use something like it in my Java project nText of that's ok (it's a simple text editor/note taker app).
Was This Post Helpful? 0
  • +
  • -

#20 gabehabe   User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1440
  • View blog
  • Posts: 11,025
  • Joined: 06-February 08

Re: Snippet Manager

Posted 25 August 2008 - 10:57 AM

Sure, no problem :)

Here's the newest version:
Attached File  Snippet_Manager_0.8.854a.zip (7.97K)
Number of downloads: 80
<edit>VERSION 1 NOW AVAILABLE HERE! :) </edit>

And here's a gift abgorn. Syntax highlighting, basic code:
		void colour (System.Drawing.Color a, string [] search, bool bold, int loop)
		{
			int z; // current caret position, use to reposition after font changes
			z = code.Selectionstart;
			int i;
			try
			{for (int x = 0; x < loop; x++)
					{
						i = code.GetFirstCharIndexFromLine(code.GetLineFromCharIndex(code.Selectionstart + 1));
				
						i = code.Text.IndexOf (search[x], i);
						if (i != -1)
						{
							code.Selectionstart = i;
							code.SelectionLength = search[x].Length;
							if (code.SelectionColor == System.Drawing.Color.Black) // if it isn't to be overridden
								code.SelectionColor = a;
							if (bold == true)
								code.SelectionFont = new System.Drawing.Font(code.Font, System.Drawing.FontStyle.Bold);
							code.DeselectAll();
							i += search[x].Length;
							
						} 
					}
				
				code.Selectionstart = z;
				code.SelectionColor = System.Drawing.Color.Black;
				code.SelectionFont = new System.Drawing.Font(code.Font, System.Drawing.FontStyle.Regular);
			} catch (System.Exception t) {} // do nothing
		}
		
		void HandleRed ()
		{
			string [] search = {"=", "/", "*", "(", ")", "[", "]"};
			colour (System.Drawing.Color.Red, search, false, 7);
		}
		
		void HandleBlue ()
		{
			string [] search = {"using", "namespace", "void", "int", "bool", "char", "for", "while",
								"do", "try", "catch", "throw", "static", "const", "class", "true",
								"false", "return", "this", "if", "else"};
			colour (System.Drawing.Color.Blue, search, true, 21);
		}
		
		void HandleGreen ()
		{
			try
			{// get the first character of the line
				int pos = code.GetFirstCharIndexFromLine(code.GetLineFromCharIndex(code.Selectionstart + 1));
				if (code.Text[pos] == '#')
					code.SelectionColor = System.Drawing.Color.Green;
			char current = code.Text[code.Selectionstart-1];
			if (current == '\n')
				code.SelectionColor = System.Drawing.Color.Black;
			}catch (System.Exception t) {}
		}


I have a nasty habit of not commenting my code. Sorry about that.
It isn't the best, it's very flawed. But it's there, all the same. :)
Was This Post Helpful? 0
  • +
  • -

#21 abgorn   User is offline

  • sudo apt install brain -y
  • member icon

Reputation: 31
  • View blog
  • Posts: 1,423
  • Joined: 05-June 08

Re: Snippet Manager

Posted 25 August 2008 - 11:56 AM

Thanks for the gift of code. So what gave you the idea to make the manager in the first place?
Was This Post Helpful? 0
  • +
  • -

#22 KYA   User is offline

  • Wubba lubba dub dub!
  • member icon

Reputation: 3213
  • View blog
  • Posts: 19,241
  • Joined: 14-September 07

Re: Snippet Manager

Posted 25 August 2008 - 12:01 PM

Can I take a stab at it and say bordem? :P
Was This Post Helpful? 0
  • +
  • -

#23 gabehabe   User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1440
  • View blog
  • Posts: 11,025
  • Joined: 06-February 08

Re: Snippet Manager

Posted 25 August 2008 - 12:02 PM

I was getting frustrated with having too many snippets, and not being able to organise them and access them through a simple-to-use program. Obvious, right?

Anyway, my next idea is to make it possible to dump the contents of the clipboard into a new folder, under a "clipboard" parent node on the tree menu. Maybe an auto dump, which only saves them for a few days~ the user can specify how many, or delete them when necessary. The feature could also be turned on/off.

Sound good?
Was This Post Helpful? 0
  • +
  • -

#24 KYA   User is offline

  • Wubba lubba dub dub!
  • member icon

Reputation: 3213
  • View blog
  • Posts: 19,241
  • Joined: 14-September 07

Re: Snippet Manager

Posted 25 August 2008 - 12:03 PM

Anything or just text?
Was This Post Helpful? 0
  • +
  • -

#25 abgorn   User is offline

  • sudo apt install brain -y
  • member icon

Reputation: 31
  • View blog
  • Posts: 1,423
  • Joined: 05-June 08

Re: Snippet Manager

Posted 25 August 2008 - 12:15 PM

Mmmm, it sounds good and do you mean a visual clipboard or the system clipboard?
Was This Post Helpful? 0
  • +
  • -

  • (11 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »