[code] Removing the filename and path from the Textadept titlebar

From: Russell Dickenson <russelldickenson.att.gmail.com>
Date: Wed, 25 Nov 2015 09:39:45 +1000

In May 2013 I asked a question to which I have only just found a
working answer. Admittedly there have been several editors in the
meantime, but I'm again warming to Textadept.

What I wanted to achieve was to have the titlebar show the following.
My aim was to remove the duplicated file's name since it took up space
for no good reason (IMO).

filename.extension - Textadept - (filepath)

I finally achieved this with some minor tweaking in Textadept's ui.lua
file, with the end result as follows:

-- Sets the title of the Textadept window to the buffer's filename.
local function set_title()
  local filename = buffer.filename or buffer._type or _L['Untitled']
  filename = filename:iconv('UTF-8', _CHARSET)
  local basename = buffer.filename and filename:match('[^/\\]+$') or filename
  local basepath = buffer.filename and filename:match('.+/') or filename
  ui.title = string.format('%s %s Textadept (%s)', basename,
                           buffer.modify and '*' or '-', basepath)
  buffer.tab_label = basename..(buffer.modify and '*' or '')

The "magic" was to create a new local variable - basepath - and use
this in the titlebar in place of filename.

I ought to note that I only achieved this with help from colleagues
more experienced in regex than I. I also need to note that if
Textadept is open with no files loaded, the titlebar then reads
"Untitled - Textadept - (Untitled)" which is not as pretty as I would
like. I'll continue tweaking this, most likely putting "Textadept" at
the end of the string. No offense intended, Mitchell. :D

Russell Dickenson
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Tue 24 Nov 2015 - 18:39:45 EST

This archive was generated by hypermail 2.2.0 : Wed 25 Nov 2015 - 06:51:10 EST