notepad-plus-plus icon indicating copy to clipboard operation
notepad-plus-plus copied to clipboard

[Feature request] Created date for a tab

Open washaqq opened this issue 1 year ago • 10 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Description of the Issue

Need created date for tabs

Describe the solution you'd like.

Sometimes i leave tabs open for a long time, and i forget the date i open that tab, it would be beneficial if there is tab created date somewhere in footer.. image

Debug Information

Notepad++ v8.6.9   (64-bit)
Build time : Jul 12 2024 - 05:09:25
Path : C:\Program Files\Notepad++\notepad++.exe
Command Line : 
Admin mode : OFF
Local Conf mode : OFF
Cloud Config : OFF
Periodic Backup : ON
OS Name : Windows 11 Home Single Language (64-bit)
OS Version : 23H2
OS Build : 22631.4037
Current ANSI codepage : 1254
Plugins : 
    mimeTools (3.1)
    NppConverter (4.6)
    NppExport (0.4)

Anything else?

No response

washaqq avatar Aug 22 '24 06:08 washaqq

Nice idea but I do not like much the status-bar placement. How about this mock-up:

npp-FR-tabopened-mockup

xomx avatar Aug 22 '24 12:08 xomx

I do not like much the status-bar placement.

Agree, forget about status-bar -- yuck.


While I think @xomx 's proposal is a nice idea, it involves code changes.

I believe @washaqq should be directed to try the Take Notes plugin. It provides an ability to create new tabs with the timestamp as the name of the tab and, importantly, also saves to disk in a true file independent of Notepad++'s control.

Also, 8.6.9 implements NPPM_SETUNTITLEDNAME which allows an unsaved-to-disk file to be renamed via a plugin, so a script could be written to rename an untitled tab to something like 240822-1103 IF the user really really wants to keep the file under Notepad++'s control and not saved independently to disk.

Finally, and most simply, users could simply use the Edit > Insert > ... commands to insert a date right into the text of their file (e.g. at the very top), as a reminder of how "old" a tab might be.

alankilborn avatar Aug 23 '24 11:08 alankilborn

so a script could be written

Such a PythonScript:

# -*- coding: utf-8 -*-
from __future__ import print_function

# references:
#  https://github.com/notepad-plus-plus/notepad-plus-plus/issues/15563  <-- this script may be found here
#  for newbie info on PythonScripts, see https://community.notepad-plus-plus.org/topic/23039/faq-desk-how-to-install-and-run-a-script-in-pythonscript

from Npp import *
import time
from ctypes import (WinDLL, WINFUNCTYPE, addressof, create_unicode_buffer)
from ctypes.wintypes import (HWND, INT, UINT, WPARAM, LPARAM)

#-------------------------------------------------------------------------------

user32 = WinDLL('user32')

try:
    notepad.hwnd  # works in PS3
except AttributeError:
    notepad.hwnd = user32.FindWindowW(u'Notepad++', None)  # needed for PS2

LRESULT = LPARAM

SendMessageW = user32.SendMessageW
SendMessageW.restype = LRESULT
SendMessageW.argtypes = [ HWND, UINT, WPARAM, LPARAM ]

WM_USER = 0x400
NPPMSG = (WM_USER + 1000)
NPPM_SETUNTITLEDNAME = (NPPMSG + 115)  # https://npp-user-manual.org/docs/plugin-communication/#2139nppm_setuntitledname

def rename_active_softnamed_tab(new_name):
    b = create_unicode_buffer(new_name)
    lp_newname = addressof(b)
    rv = SendMessageW(notepad.hwnd, NPPM_SETUNTITLEDNAME, notepad.getCurrentBufferID(), lp_newname)
    return rv

#-------------------------------------------------------------------------------

class NTWDAIN(object):

    def __init__(self):
        notepad.new()
        t = time.strftime("%y%m%d-%H%M%S", time.localtime())
        rename_active_softnamed_tab(t)

#-------------------------------------------------------------------------------

if __name__ == '__main__': NTWDAIN()

Running the script creates a new tab (thus running the script would be used instead of File > New):

image

alankilborn avatar Aug 23 '24 11:08 alankilborn

Nice idea but I do not like much the status-bar placement. How about this mock-up:

npp-FR-tabopened-mockup

Fine for me, i just want to see it without clicking couple of buttons.

Edit 1: i just thought this is best option.

washaqq avatar Aug 23 '24 13:08 washaqq

I do not like much the status-bar placement.

Agree, forget about status-bar -- yuck.

While I think @xomx 's proposal is a nice idea, it involves code changes.

I believe @washaqq should be directed to try the Take Notes plugin. It provides an ability to create new tabs with the timestamp as the name of the tab and, importantly, also saves to disk in a true file independent of Notepad++'s control.

Also, 8.6.9 implements NPPM_SETUNTITLEDNAME which allows an unsaved-to-disk file to be renamed via a plugin, so a script could be written to rename an untitled tab to something like 240822-1103 IF the user really really wants to keep the file under Notepad++'s control and not saved independently to disk.

Finally, and most simply, users could simply use the Edit > Insert > ... commands to insert a date right into the text of their file (e.g. at the very top), as a reminder of how "old" a tab might be.

I don't insist on the status bar, I just want to see it without clicking some buttons and accessing some menus, I don't use plugins too much and I'm not a fan of scripting because plugins and scripts are easily brake when new update comes, I like things naturally. If possible, please code it in source.

washaqq avatar Aug 23 '24 13:08 washaqq

I don't use plugins too much

Well, the N++ author usually doesn't entertain adding functionality into the core that is achievable via plugins...


not a fan of scripting because plugins and scripts are easily brake when new update comes

Untrue.


Summary: I've given several choices that allow you to have the functionality today, whether or not you choose to try any of those and see if they are workable is up to you.


@xomx

While your suggestion isn't bad, I think, if the time-created data were to be added to the UI, it should be added under View > Summary data. Users can't object too much if they have to assign a shortcut to that command and press one keycombo when they desire to see this not-so-often needed piece of information. It keeps the info in one place, not divided among two places.

alankilborn avatar Aug 23 '24 14:08 alankilborn

@alankilborn

time-created data were to be added to the UI

It is not about time-created, it is about when the N++ tabs were opened (both with the unsaved newxxx and with the regular files).

I see this potential new feature as a N++ tab property rather than an open file/doc property. That is why I preferred to use a tab-tooltip (the right-click tab pop-up menu is also acceptable place for me) rather than a doc status-bar or e.g. your suggested doc summary.

For me personally, this could be useful while managing old many-file sessions...

xomx avatar Aug 23 '24 15:08 xomx

It is not about time-created, it is about when the N++ tabs were opened

That IS a time created; the time the tab was created so that a file could be opened into it.

If there is other metadata that would be tab-related only (can't think of any), then it might be appropriate in a bigger tooltip. I still think it works better in View > Summary. It could be:

File path: ...
Opened: ...
Created: ...
Modified: ...
...

alankilborn avatar Aug 23 '24 20:08 alankilborn

@alankilborn

the time the tab was created

Ok, this time no objections to this rephrasing from my side.

If there is other metadata that would be tab-related only (can't think of any),

For now I do not know such either, but I can think of the possibility of using this as another hint for the inexperienced users (you know - those who grew up only on mobile phones and carelessly store their valuable data only in the "newxxx" tabs for months...). Just for a further highlighting of the difference between an opened regular file and an unsaved tab, mock-up No. 2:

npp-FR-tabopened-mockup2

I still think it works better in View > Summary.

But this will not fulfill the OP's request (and my laziness, I admit), hovering over the tabs (even the inactive ones) is simply faster:

I don't insist on the status bar, I just want to see it without clicking some buttons and accessing some menus,

xomx avatar Aug 23 '24 23:08 xomx

not a fan of scripting because plugins and scripts are easily brake when new update comes

Untrue.

Well, it depends, my experience tells me so

washaqq avatar Aug 25 '24 18:08 washaqq

Hi @xomx,

Any progress? what are you going to do about this, is it on your agenda? or shall i forget about it and close the issue?

Thanks.

washaqq avatar Sep 12 '24 07:09 washaqq

@washaqq No progress - unfortunately no time. Yes, I put it on my TODO. Definitely do not close this FR issue, maybe someone else with more free time will do it.

But 1st step 1st - before anyone goes any further, the project maintainer should have given green light to such an idea, otherwise it is a waste of time.

@donho What do you think?

Here is another possible mock-up: npp-tab-tooltip-mockup3

From the coding POV it should not be more than adding another SYSTEMTIME to the session.xml to store and one new corresponding N++ tab-buffer member var (+ adjusting the tab tooltip creation).

Rationale summary:

  • better maintainability of an older many files session
  • better highlighting of the difference between using regular files and unsaved N++ tabs (mainly for the inexperienced users...)
  • tab-tooltip place as it is a N++ tab property rather than an open file/doc property

xomx avatar Sep 12 '24 09:09 xomx

@washaqq No progress - unfortunately no time. Yes, I put it on my TODO. Definitely do not close this FR issue, maybe someone else with more free time will do it.

But 1st step 1st - before anyone goes any further, the project maintainer should have given green light to such an idea, otherwise it is a waste of time.

@donho What do you think?

Here is another possible mock-up: npp-tab-tooltip-mockup3

From the coding POV it should not be more than adding another SYSTEMTIME to the session.xml to store and one new corresponding N++ tab-buffer member var (+ adjusting the tab tooltip creation).

Rationale summary:

  • better maintainability of an older many files session
  • better highlighting of the difference between using regular files and unsaved N++ tabs (mainly for the inexperienced users...)
  • tab-tooltip place as it is a N++ tab property rather than an open file/doc property

Thanks for the feedback, then i will wait (maybe forever 😊).

washaqq avatar Sep 12 '24 14:09 washaqq

Just wanted to say I need this too)) Glad someone is working on it!

ivangretsky avatar Sep 13 '24 17:09 ivangretsky

@donho What do you think?

Here is another possible mock-up:

Before saying "Hmm... it could be a useful.", the essential question is: What are the definition of "Created date" and "Opened date"? They are different to me.

Once we have the definitions, we can talk about this feature furthermore.

donho avatar Sep 13 '24 23:09 donho

What are the definition of "Created date" and "Opened date"? They are different to me.

It should reflect "the date the session file tab in N++ was first created". And this date should remain the same until the user closes that session file.

I see a problem with both the "opened" and "created" because the tab with the same session file can be recreated/reopened multiple times when the N++ is exited and then launched again (with the same session). So the simple "opened" or "created" does not accurately describe the matter and it would like be something better (but also short).

So maybe "TAB first created: " ?

xomx avatar Sep 14 '24 09:09 xomx

Well actually both can work, created date for unsaved tab, opened date for saved and opened, so created date will be turn into opened when saved file opened otherwise it is created date for unsaved tab. I hope it is not tangled.

washaqq avatar Sep 15 '24 20:09 washaqq

Thank you for your definition. It helps me to see the need.

What I see this feature should be (a tiny specs):

  1. For only unsaved tab, it displays the tip: "New 1\nCreated: 2024-07-10"
  2. Once the unsaved tab is saved, display no more the creation date.
  3. Use part of creation date of backup file name for displaying. For example, the date "2024-07-10" of the tip "New 1\nCreated: 2024-07-10" comes from the backup file name "New 1@2024-09-16_003937" - The creation date should not be stored in session.xml.

Does it sound reasonable the above description to you guys?

donho avatar Sep 15 '24 22:09 donho

@donho

Pros:

  • clever reuse of existing info from the backup file naming, so no need to store&handle new SYSTEMTIME session-tab-creation value for session.xml

Cons:

  • not universal, e.g. no such N++ tab-metadata info at all for the tabs with regular unmodified files (sometimes I also need to know when I opened a file in my many-files session...)
  • dependency on another N++ setting (Preferences > Backup > Enable session snapshot and periodic backup, it has to be ON), I can imagine that someone keeps the N++ app still running & without that backups enabled, so then there will be nothing to get this metadata from...

Anyway, if you implement it as you suggested, please include also that hhmmss part info from the backup name (i.e. 2024-09-05 16:12:10 for the new 1@2024-09-05_161210).

xomx avatar Sep 16 '24 12:09 xomx

@xomx

not universal, e.g. no such N++ tab-metadata info at all for the tabs with regular unmodified files (sometimes I also need to know when I opened a file in my many-files session...)

Sorry, I don't follow you at all. Could you elaborate it?

dependency on another N++ setting (Preferences > Backup > Enable session snapshot and periodic backup, it has to be ON), I can imagine that someone keeps the N++ app still running & without that backups enabled, so then there will be nothing to get this metadata from...

In the case that "Enable session snapshot and periodic backup" is not turn on, there are 2 ways to define the behaviour:

  1. Tip not include the creation date.
  2. Assign the current time to created tab as creation date to the date.

I personally prefer the 1st one, as it is simpler.

Anyway, if you implement it as you suggested, please include also that hhmmss part info from the backup name (i.e. 2024-09-05 16:12:10 for the new 1@2024-09-05_161210).

Why not? But only date - no time to be included in my mini specs above. Since I'm not for such feature, I'm not gonna implement it. I just want to make sure that the logic is simple and no redundant storage if this feature is implemented by someone.

donho avatar Sep 17 '24 01:09 donho

Thank you for your definition. It helps me to see the need.

What I see this feature should be (a tiny specs):

  1. For only unsaved tab, it displays the tip: "New 1\nCreated: 2024-07-10"
  2. Once the unsaved tab is saved, display no more the creation date.
  3. Use part of creation date of backup file name for displaying. For example, the date "2024-07-10" of the tip "New 1\nCreated: 2024-07-10" comes from the backup file name "New 1@2024-09-16_003937" - The creation date should not be stored in session.xml.

Does it sound reasonable the above description to you guys?

I agree with @xomx on 3rd item. people may not enable backup setting, i even didn't know that it exists, so i just checked if it is enabled.

can you mention someone who may implement it. Thanks.

washaqq avatar Sep 19 '24 14:09 washaqq

@donho

not universal, e.g. no such N++ tab-metadata info at all for the tabs with regular unmodified files (sometimes I also need to know when I opened a file in my many-files session...)

Sorry, I don't follow you at all. Could you elaborate it?

It comes handy to me to quickly see when I first opened any tab in the session (be it newXXX unsaved, or some existing file), like:

npp-tab-tooltip-mockup4

npp-tab-tooltip-sessionxml-item

xomx avatar Sep 19 '24 15:09 xomx

@xomx So you want to have "Created date" not only for the untitled document (which could be helpful), but also for all the existent on disk files (dirty or not), right?

The "Created date" for the untitled document is the creation date of tab obviously. However, what will be the "Created date" for the existent on disk files? The creating time of file on the disk or the time when user open it in Notepad++? If your answer is the 2nd one, why do you need it?

donho avatar Sep 20 '24 02:09 donho

@donho

So you want to have "Created date" not only for the untitled document (which could be helpful), but also for all the existent on disk files (dirty or not), right?

Yes.

However, what will be the "Created date" for the existent on disk files? The creating time of file on the disk or the time when user open it in Notepad++?

"or the time when user 1st open it in Notepad++?". As this whole issue is named/about "Created date for a tab", not for a file.

If your answer is the 2nd one, why do you need it?

IMO - having this new feature for the newXXX tabs is more important.

But if it will be there, I can imagine that having the same info for an opened file-tab will help me to maintain my N++ sessions. It is just another useful information, but it is not essential, of course. E.g. I have one multi-file log session open, and if I see the mentioned tab-info, I will know from what moment I have started watching for a particular log.

xomx avatar Sep 22 '24 17:09 xomx

I use notepad++ as a sort of quick notes app. I've got hundreds of tabs open. When I finally start to sort them out I really want to know when the tab was first created. If there could be info on when the file created with notepad++ was first started as a tab that would help me personally too, as that would let me deal with saved and not saves tabs same way and not require me to have that initial creation date in filename.

ivangretsky avatar Sep 22 '24 18:09 ivangretsky

@ivangretsky @washaqq Could you let me know if you guys need the created date info for the opened existent files (if yes, please elaborate the reason), or you need only this info for the untitled tab (by example: "new 1", "new 2", etc...) ?

donho avatar Sep 23 '24 14:09 donho

As for me I am ok with dates only for the not-yet-saved tabs. I can understand that saving tab creation date somewhere is not an obvious task. Wanted this just in case.

ivangretsky avatar Sep 23 '24 18:09 ivangretsky

@ivangretsky Thank you for your confirmation.

@xomx I want to know the concrete usage of created date on existent files, because there is not enough room to display the full path + the create date (and I would like keep it simple as well), also I don't want to add one more option Display "Tab Create Date" on tab tooltip in preferences dialog to display or not the created date on both untitled tabs & existing files.

OTOH, it's OK to me to display the created date only for "new tab #" without any new added option. And it's only when the snapshot is ON - it makes sense to me that the information comes from the backup file (it'll be the created date in file attribute instead from the part of backup files' name).

donho avatar Sep 23 '24 20:09 donho

@donho

Ok, your reasoning makes sense, I like the KISS too. Moreover, now that I have thought about it more, displaying that metadata info also for the tabs with regular files might confuse some users rather than help them.

I have only one note - rather than making the tab-timestamp info dependent on the (optionally enabled) backup snapshots files, I would do it the other way around - making the N++ backup file-naming dependent on the N++ tab-timestamps. So then the tab-timestamp info will be passed/stored by naming the possible N++ backup-snapshot files (and not via storing another item in the session.xml file as I suggested before or by checking the file-times as you suggested).

  1. Create one new member var e.g. std::wstring _tabTimeStampStr; for the N++ buffer class and initialize it always (e.g. to the currently in N++ used "yyyy-mm-dd_hhmmss") when a new N++ tab is created and then:
  • 2A - when the N++ backup snapshot is OFF - use this all the time for the tab-tooltip creation until a user does not close N++ or the tab or saves it to a regular file (use-case: user can keep the N++ app still running without the snapshots enabled for weeks and use rather the Windows sleep/hibernation instead of the traditional restart/shutdown)
  • 2B - when the N++ backup is ON - use this for the initial backup filename creation (and after a possible closing&relaunch of the N++, parse&load this value back into the member var _tabTimeStampStr from there once at the N++ init)

Doing so would allow the same info for users not using the N++ backup snapshot feature. That way we can also avoid unnecessary file IO usage because otherwise the GetFileAttributes for the relevant tab backup-file will be called every time the mouse hovers over a newXXX tab. It then also covers corner cases like when a user switches temporarily N++ snapshots OFF (ON/OFF/ON), so the backup snapshot file will have a new filetime etc...

xomx avatar Sep 24 '24 15:09 xomx

@xomx If you have tried the latest status of PR #15651, you will see all the new tab (periodic backup activated or not) will have the created date. However, when the periodic backup is activated, there might be a undesired behaviour: While create the new tab (empty & clean), there will be a created time displayed. When the document is modified, a new created time will be assigned and displayed. But the time of the first modification which makes empty document dirty will be remained.

donho avatar Sep 26 '24 02:09 donho