Skip to main content

Ralsina.Me — Roberto Alsina's website

Posts about marave

Free software is good for me.

I make a liv­ing work­ing with free soft­ware (BTW, if you need sysad­mins that know what they do, con­tact us: http://www.net­man­ager­s.­com.ar)

But that's not that big a deal, I could make a liv­ing do­ing some­thing else. I am sure I would be com­pe­tent at some­thing else, even if I have no idea what that would be right now.

It does, how­ev­er give me free­dom to play, which is much more im­por­tan­t. There­fore, this post is sort of a sta­tus up­date on things I play with. Not games, those are not re­al­ly my thing, but things that I do for fun.

Yes, some of these may mean I am a very strange per­son.

I'll lim­it my­self to the last cou­ple of weeks or so.

There's been sort of a bump in in­ter­est in Mar­ave, my dis­trac­tion free ed­i­tor and it's be­cause it has been re­viewed in Lin­ux Jour­nal!

I have read the ar­ti­cle (sad­ly I can't link to it) and it was a su­per pos­i­tive re­view, here are some choice quotes:

"mar­ave makes the dull world of text edit­ing ro­man­tic and im­mer­sive with beau­ti­ful min­i­mal­is­m"

"... it does­n't just have min­i­mal­ism and sim­plic­i­ty, it has min­i­mal­ism and sim­plic­i­ty com­bined with beau­ty and a pal­pa­ble de­sign eth­ic. mar­ave has soul, and I love that."

So thanks for the kind words to the au­thor, and some­thing I no­ticed: you ran in­to a big bug in mar­ave and did­n't no­tice :-)

The "crick­et bat" icon (it's a screw­driv­er ;-) should show you the con­fig di­a­log. How­ev­er, it seems in Ubun­tu (and maybe in oth­er dis­tros, I don't know) the con­fig is not vis­i­ble,and all you see is the text move around a bit. This is what he should have seen:

marave15

I have nev­er been able to re­pro­duce it, but I am go­ing to in­stall a Ubun­tu VM just for this, so maybe soon.

On re­lat­ed news, mar­ave was al­so re­viewed in a ger­man mag­a­zine a cou­ple of months ago, and I have not been able to get a copy of the ar­ti­cle. (BTW, is­n't it rea­son­able to send a copy of these to the au­thor of the pro­gram you are re­view­ing? Nei­ther mag­a­zine even men­tioned it to me!)

In any case, if any­one has this mag­a­zine and can tell me what the ar­ti­cle about dis­trac­tion-free ed­i­tors say, you will make my day:

Here's the ar­ti­cle teas­er

And this seems to be the mag­a­zine is­sue:

https://shop.linuxnewmedia.de/store/eh01/EH10165/de/product_image/variant/bounding_product

On new projects (yes, I al­ways have new pro­ject­s), I ran in­to this awe­some blog post by Roger Als­ing about ap­proach­ing Mona Lisa with just 50 poly­gons <http://roger­als­ing.­com/2008/12/07/­ge­net­ic-pro­gram­ming-evo­lu­tion-of-­mon­a-lisa/ > and be­ing a nerd and hav­ing awe­some pro­gram­ming tools at my com­mand... I wrote a frame­work to test that kind of al­go­rithm­s.

I called it evo­lu­to and it's at http://evo­lu­to.­google­code.­com.

I on­ly did a very sim­ple al­go­rith­m, based on translus­cent tri­an­gles, but it did work... for some def­i­ni­tion of work!

You can even see the lo­cal min­i­mum that does­n't let her right eye form right :-)

Evo­lu­to has a li­brary of al­go­rithms (cur­rent­ly emp­ty) and you can ed­it and reap­ply on-the-fly the one you wan­t, and see the gen­er­a­tions change on-screen.

It would take some work to make it a pol­ished pro­gram, but it does work.

I folled around a bit with cre­at­ing a nice PDF pre­sen­ta­tion play­er but it's still very ear­ly:

109301062

In what's per­haps my most es­tab­lished pro­jec­t, rst2pdf. I have fixed a bunch of bugs, and a re­lease is a bit over­due:

Issue 186: Text not wrapping around images when specified

I fixed this by adding a new CLI op­tion, so be­hav­iour was not changed, but now you can have im­ages with text flow­ing be­side it. It will not look great but it work­s.

Issue 307: Replace directive doesn't replace text in header/footer in some cases

This was an in­ter­est­ing prob­lem! It was very en­ter­tain­ing.

Made it work with Sphinx 1.*

There is a piece bro­ken stil­l, but what I fixed was not ter­ri­bly hard.

Unbroken bookrest

I need to work much more with this, but at least what worked be­fore works again. If you don't know what bookrest is, it's a rst2pdf graph­i­cal fron­tend / word pro­ces­sor, here's a taste:

I al­so made sev­er­al re­leas­es for my AUR pack­ages

Plus I worked, and some oth­er stuff. All in al­l, not a bad stretch.

Marave 0.7 released

I just up­load­ed ver­sion 0.7 of Mar­ave, my fullscreen text ed­i­tor to http://­mar­ave.­google­code.­com

Mar­ave is a "re­lax­ing" text ed­i­tor in­spired by ommwriter, Dark­Room and many oth­er­s. It com­bines a spar­tan fullscreen UI with a van­ish­ing UI, which gets out of the way of your tex­t.

It sup­ports syn­tax high­light­ing, inine spellcheck­ing, back­ground mu­sic, au­di­ble key­board feed­back, themes, is ex­ten­si­ble via plu­g­in­s, and much more.

Here's a screen­shot:

marave18

There are no ma­jor new fea­tures in 0.7, but there are im­por­tant in­ter­nal changes and some ma­jor bugs fixed:

  • Fixed bug that broke open­ing files if you had no spellcheck­­er

  • Im­­ple­­men­t­ed ba­sic RTL lan­guage sup­­port

  • Sev­er­al oth­­er mi­nor fix­es

  • Refac­­tored the ed­i­­tor com­po­­nent so it can be reused

Are we really this clueless about software costs?

Here's what Ohloh has to say about the cost of de­vel­op­ing Mar­ave

Re­al­ly, Mar­ave is maybe a month of part-­time pro­gram­ming. How could that pos­si­ble be U$S71355, or "1 Per­son Years"?

Is this garbage the best we have to es­ti­mate cost­s? If that's the case, then when­ev­er you see some­thing about "Open source pro­gram X would take Y years and cost Z dol­lars to write", cut it down by a fac­tor of 10 or more.

Here's what Mar­ave re­al­ly cost­ed to de­vel­op:

  • Noth­ing.

Ok, here's what it would have cost­ed if I had charged for it:

I am guess­ing about 100 hours of my time. At my "I hope they pay me this much" rate of U$S 40/hour , that's U$S 4000, which means Ohloh is off by 1600%.

OTO­H, for that much free­lance work I would not charge you the full rate, I would prob­a­bly end charg­ing you more like U$S20/hour which would make Ohlo­h's guess over 3000% too high.

In con­clu­sion: if you like my code (and hey, you can see it for your­self), hire me, I am in­cred­i­bly cheap, or amaz­ing­ly fast!

Marave 0.6 is out

Ver­sion 0.6 of Mar­ave, my peace­ful, fullscreen text ed­i­tor is now avail­able at the usu­al place: http://­mar­ave.­google­code.­com

New stuff:

  • Syn­­tax high­­­lighter

  • Plug­ins

  • Bugs fixed

  • Nicer an­i­­ma­­tions

  • Code cleanup

Gra­tu­itous screen­shot:

Extending Marave

Mar­ave is a text ed­i­tor. If there's one thing that's true of most text ed­i­tors, it's this: they lack the ex­act fea­tures you need.

So, the so­lu­tion, in the an­cient tra­di­tion of Emacs and Vim is... make it ex­ten­si­ble.

I am a big fan of pro­grams that can be ex­tend­ed by users.

So... here's the anato­my of a Mar­ave plug­in as it stands right now on SVN trunk, which of course can change any minute.

Creating a plugin

You just need to cre­ate a .py file in the plug­ins fold­er.

Here's the most ba­sic plug­in, which does noth­ing:

# -*- coding: utf-8 -*-

from plugins import Plugin
class Smarty(Plugin):
    name='smarty'
    shortcut='Ctrl+.'
    description='Smart quote and dash replacement'
    mode="qBde"

De­fault val­ues for any­thing con­fig­urable (in this case, "mod­e") is just added to the class.

The manda­to­ry field­s:

  • short­­­cut: a key­board short­­­cut that trig­gers this plug­in

  • name: a short name

  • de­scrip­­tion: a one-­­line de­scrip­­tion of what it does

What does it do? It adds the plug­in to the plug­in list in the prefs di­alog, and you can open its con­fig­u­ra­tion di­alog, where you can change the short­cut:

maraveplugin1

If you en­able this plug­in, when­ev­er the short­cut is used the "run" method of the plug­in is called.

Making the Plugin Configurable

This plug­in sup­ports dif­fer­ent modes of op­er­a­tion. To make this reach­able to the user, you need to im­ple­ment a few ex­tra meth­od­s.

The ad­d­Con­fig­Wid­gets method takes a di­a­log ar­gu­ment and adds what­ev­er you want there:

@classmethod
def addConfigWidgets(self, dialog):
    print 'Adding widgets to smarty config'
    l=dialog.ui.layout
    self.q=QtGui.QCheckBox(dialog.tr('Replace normal quotes'))
    if 'q' in self.mode:
        self.q.setChecked(True)
    self.b=QtGui.QCheckBox(dialog.tr('Replace backtick-style quotes (` and ``)'))
    if 'B' in self.mode:
        self.b.setChecked(True)
    self.d=QtGui.QCheckBox(dialog.tr('Replace -- by en-dash, --- by em-dash'))
    if 'd' in self.mode:
        self.d.setChecked(True)
    self.e=QtGui.QCheckBox(dialog.tr('Replace ellipses'))
    if 'e' in self.mode:
        self.e.setChecked(True)
    l.addWidget(self.q)
    l.addWidget(self.b)
    l.addWidget(self.d)
    l.addWidget(self.e)

And then the con­fig di­a­log will look like this:

maraveplugin2

But then you need to save those op­tions some­where, which you do reim­ple­ment­ing save­Con­fig:

@classmethod
def saveConfig(self, dialog):

    self.shortcut=unicode(dialog.ui.shortcut.text())
    self.settings.setValue('plugin-'+self.name+'-shortcut', self.shortcut)

    newmode=""
    if self.q.isChecked():
        newmode+='q'
    if self.b.isChecked():
        newmode+='B'
    if self.d.isChecked():
        newmode+='d'
    if self.e.isChecked():
        newmode+='e'
    self.mode=newmode

    self.settings.setValue('plugin-smarty-mode',self.mode)
    self.settings.sync()

And you need to load those set­tings and put them in your class, too:

@classmethod
def loadConfig(self):
    print 'SMARTY loadconfig', self.settings
    if self.settings:
        sc=self.settings.value('plugin-'+self.name+'-shortcut')
        if sc.isValid():
            self.shortcut=unicode(sc.toString())
        mode=self.settings.value('plugin-smarty-mode')
        if mode.isValid():
            self.mode=unicode(mode.toString())

Making it Work

And yes, you need to make it do some­thing use­ful. The plug­in has ac­cess to a "clien­t" which is Mar­ave's main win­dow. Ev­ery­thing is avail­able there, some­where ;-)

def run(self):
    print 'running smarty plugin'
    text=unicode(self.client.editor.toPlainText()).splitlines()
    prog=QtGui.QProgressDialog(self.client.tr("Applying smarty"),
                               self.client.tr("Cancel"),
                               0,len(text),
                               self.client)
    prog.show()
    output=[]
    for i,l in enumerate(text):
        output.append(unescape(smartyPants(l,self.mode)))
        prog.setValue(i)
        QtGui.QApplication.instance().processEvents()
    prog.hide()
    self.client.editor.setPlainText('\n'.join(output))

And there it is, if you en­able the smar­ty plug­in, you can "fix" your quotes, dash­es and el­lip­sis with a key com­bi­na­tion :-)

Full source code here: http://­code.­google.­com/p/­mar­ave/­source/browse/trunk­/­mar­ave/­plu­g­in­s/s­mar­ty.py

Still to be done: oth­er ways to in­te­grate plug­ins in­to the UI, but­ton­s, pan­el­s, etc.


Contents © 2000-2023 Roberto Alsina