Omnimaga

General Discussion => Technology and Development => Computer Projects and Ideas => Topic started by: AngelFish on August 22, 2011, 08:55:48 pm

Title: Yet Another Brainf*ck Text Editor
Post by: AngelFish on August 22, 2011, 08:55:48 pm
Introducing the future of text editors, the Tidal editor. Hand-written in raw, optimized Brainf*ck (after being ported from both the TI-84+ and Casio FX-CG families of calculators) and released under a GPL license for this exclusive beta download, Tidal is the fastest and most powerful Brainf*ck text editor around.

Spoiler For Screenshots:
(http://img.removedfromgame.com/imgs/Tidal.png)

Spoiler For Usage:
Tidal is a standard text editor designed to work with the Brainf*ck Developer (http://4mhz.de/bfdev.html). Normal usage is very simple: Just type in the text you want to edit on the input line. Backspace is used by entering the "~" character as input. Also, please comment about features you'd like to see added to Tidal, such as a native brainf*ck interpreter or dynamic refresh.

Spoiler For Source:
Quote
+[-,>,----------[++++++++++>][-][<]<[>+>+<<-]+>-[<+>-]>>>>+++++++[
<+++++++++>-]<[<++>-]<<[>-<-]>[>>]<<[-]<[-]<+]

Title: Re: An epic Brainf*ck text editor
Post by: yunhua98 on August 22, 2011, 09:01:16 pm
its really that small?  :o
Title: Re: An epic Brainf*ck text editor
Post by: AngelFish on August 22, 2011, 09:02:20 pm
The text editor core is like five instructions :P

The rest of that is just parsing inputs.
Title: Re: An epic Brainf*ck text editor
Post by: NecroBumpist on August 22, 2011, 10:20:43 pm
I love brainf*ck! I also love ><> :)
Title: Re: Yet Another Brainf*ck Text Editor
Post by: thepenguin77 on August 23, 2011, 12:19:09 am
Way to go Qwerty, it works great. I typed it into my on-calc BrainF*ck compiler and it worked great. The only problem was that I had no way to type ~, and I feel like half the code is devoted to backspacing...


its really that small?  :o

It's actually pretty long if you type it out. It took 8 full lines in the basic editor.
Title: Re: Yet Another Brainf*ck Text Editor
Post by: AngelFish on August 23, 2011, 12:25:42 am
Yeah, the equality test I used for ~ is... slightly long. But if you want to replace "~" with your own value, just change this part of the code to generate the character value you want:
Code: [Select]
+++ ++++[<+++ +++ +++>-]<[<++>-] That's set to 0x7E or 126 in the regular code. The test works for any value.

On a side note, I still have features planned for this simply to see if I can implement them :D
Title: Re: Yet Another Brainf*ck Text Editor
Post by: thepenguin77 on August 23, 2011, 12:54:46 am
I made it use 'z' = 0x7A by simply adding -- right before the final [<++>-]. But then nothing changed.

So I debugged the whole thing and I saw the magic in action. It was so cool to see the whole thing work out perfectly and end with 00's. But what I saw is that it doesn't actually update the screen, it just deletes the memory. So now I know.
Title: Re: Yet Another Brainf*ck Text Editor
Post by: AngelFish on August 23, 2011, 12:56:46 am
There are a few interpreter oddities that make refreshing the screen a PITA to do consistently, so that's one of the things I want to figure out next.
Title: Re: Yet Another Brainf*ck Text Editor
Post by: JustCause on August 23, 2011, 03:53:24 pm
This is incredible. HOW DO YOU DO THIS.
Title: Re: Yet Another Brainf*ck Text Editor
Post by: AngelFish on September 28, 2011, 12:37:07 pm
I went back and commented the source for anyone who's curious about how the magic happens. There might be a few minor errors because I lost the original (commented) source to this, so I had to figure out what was going on again.

Code: [Select]
+[-,> // notice the similarities of this code to the main interpreter loop code of "+[-,>+]"
     , // handle the \n most editors insert after input where the character code for \n is 0x10
 ----------[++++++++++>] // subtract 0x10 from second cell. If still non-zero (for multi-character input),
  // restore it and switch to next cll
  [-] // zero the value of the cell to operate on (to handle bad interpreter memory initialization)
  [<]< // go backwards to the last character entered
  [>+>+<<-]+>-[<+>-] // copy character entered out to next two cells
  >>>>+++++++[<+++++++++>-]<[<++>-]<< // the character code for "~" is 0x7E which can be factored as 7*9*2
  [>-<-]> // subtract the character code from 126
  [>>]<< // if 0, move pointer back to value of character in memory
  // otherwise nothing happens
  [-]< // erase value of cell containing previous character code (if current code is 0x7E)
  [-]<+ // clean up memory normally

 ]
Title: Re: Yet Another Brainf*ck Text Editor
Post by: ben_g on September 28, 2011, 01:37:39 pm
what's Brainf*ck?
Title: Re: Yet Another Brainf*ck Text Editor
Post by: Ashbad on September 28, 2011, 04:55:19 pm
This is incredible. HOW DO YOU DO THIS.

You type the code and it does stuff.  In cases like this, sometimes cool stuff.

what's Brainf*ck?

The classic Esoteric Language (basically, a language that exists either as a joke or to challenge programmers), that has a tendency to F*ck your Brain.  Hence, the fitting name :)