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

From: Michal Kottman <k0mpjut0r.att.gmail.com>
Date: Wed, 25 Nov 2015 12:22:23 +0100

On Nov 25, 2015 12:40 AM, "Russell Dickenson" <russelldickenson.att.gmail.com>
wrote:

> -- 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 '')
> end
>
> 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

In the 'Untitled'/no file case, you can just use a different title, e.g.:

-- Sets the title of the Textadept window to the buffer's filename.
local function set_title()
  if not (buffer.filename or buffer.type) then
    ui.title = 'Untitled'
    buffer.tab_label = 'Untitled'
    return
  end
  local filename = buffer.filename or buffer._type
  ...

-- 
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 Wed 25 Nov 2015 - 06:22:23 EST

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