Re: [code] Re: How can I tweak the text shown on Textadept's titlebar?

From: Mitchell <>
Date: Tue, 28 May 2013 10:35:54 -0400 (Eastern Daylight Time)

Hi Russell,

On Tue, 28 May 2013, Russell Dickenson wrote:

> Sorry - I somehow sent my previous message before I had finished composing
> it. :O
> I want to modify the text so that it's <FILENAME> (FILEPATH) - Textadept
> Is there a native function for obtaining a given file's path?
> On 28 May 2013 08:40, Russell Dickenson <> wrote:
>> I want to change the text shown on Textadept's titlebar so that the name
>> of the open file is not repeated. I have found where in the code this is
>> set, but don't know how to achieve what I want.
>> The code I have found is as follows (from gui.lua)
>> -- Sets the title of the Textadept window to the buffer's filename.
>> -- @param buffer The global buffer.
>> local function set_title()
>> local filename = buffer.filename or buffer._type or _L['Untitled']
>> local basename = buffer.filename and filename:match('[^/\\]+$') or
>> filename
>> gui.title = string.format('%s %s Textadept (%s)', basename,
>> buffer.dirty and '*' or '-', filename)
>> end

You need to connect to the `events.UPDATE_UI` event. (*gui.lua* does this
to call the internal `set_title()` you found.) Something like this should
work (untested though):

     events.connect(events.UPDATE_UI, function()
       local name, path
       if buffer.filename then
         path, name = buffer.filename:match('^(.+[/\\])([^/\\]+)$')
         name, path = buffer._type or _L['Untitled'], ''
       gui.title = string.format('%s (%s) %s Textadept', name, path,
                                 buffer.dirty and '*' or '-')

There is no function to obtain a file's path. You must use Lua patterns
like the above code does.


You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Tue 28 May 2013 - 10:35:54 EDT

This archive was generated by hypermail 2.2.0 : Wed 29 May 2013 - 06:54:20 EDT