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

From: Russell Dickenson <russelldickenson.att.gmail.com>
Date: Wed, 29 May 2013 08:01:53 +1000

Mitchell,

Thanks for your reply. I'll work on that and see what I can come up with.

On 29 May 2013 00:35, Mitchell <m.att.foicica.com> wrote:

> 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 <russelldickenson.att.gmail.com>
>> 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('^(.+[/\**\])([^/\\]+)$')
> else
> name, path = buffer._type or _L['Untitled'], ''
> end
> gui.title = string.format('%s (%s) %s Textadept', name, path,
> buffer.dirty and '*' or '-')
> end)
>
> There is no function to obtain a file's path. You must use Lua patterns
> like the above code does.
>
> Cheers,
> Mitchell
> --
> 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.
>
>

-- 
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 28 May 2013 - 18:01:53 EDT

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