Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Created date for a tab #15563

Closed
1 task done
washaqq opened this issue Aug 22, 2024 · 33 comments
Closed
1 task done

[Feature request] Created date for a tab #15563

washaqq opened this issue Aug 22, 2024 · 33 comments
Assignees
Labels

Comments

@washaqq
Copy link

washaqq commented Aug 22, 2024

Is there an existing issue for this?

  • 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

@xomx
Copy link
Contributor

xomx commented Aug 22, 2024

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

npp-FR-tabopened-mockup

@alankilborn
Copy link
Contributor

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
Copy link
Contributor

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

@washaqq
Copy link
Author

washaqq commented Aug 23, 2024

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
Copy link
Author

washaqq commented Aug 23, 2024

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.

@alankilborn
Copy link
Contributor

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.

@xomx
Copy link
Contributor

xomx commented Aug 23, 2024

@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...

@alankilborn
Copy link
Contributor

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: ...
...

@xomx
Copy link
Contributor

xomx commented Aug 23, 2024

@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,

@washaqq
Copy link
Author

washaqq commented Aug 25, 2024

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
Copy link
Author

washaqq commented Sep 12, 2024

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.

@xomx
Copy link
Contributor

xomx commented Sep 12, 2024

@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

@washaqq
Copy link
Author

washaqq commented Sep 12, 2024

@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 😊).

@ivangretsky
Copy link

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

@donho
Copy link
Member

donho commented Sep 13, 2024

@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.

@xomx
Copy link
Contributor

xomx commented Sep 14, 2024

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: " ?

@washaqq
Copy link
Author

washaqq commented Sep 15, 2024

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.

@donho
Copy link
Member

donho commented Sep 15, 2024

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?

@xomx
Copy link
Contributor

xomx commented Sep 16, 2024

@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).

@donho
Copy link
Member

donho commented Sep 17, 2024

@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.

@washaqq
Copy link
Author

washaqq commented Sep 19, 2024

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.

@xomx
Copy link
Contributor

xomx commented Sep 19, 2024

@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

@donho
Copy link
Member

donho commented Sep 20, 2024

@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?

@xomx
Copy link
Contributor

xomx commented Sep 22, 2024

@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.

@ivangretsky
Copy link

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.

@donho
Copy link
Member

donho commented Sep 23, 2024

@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...) ?

@ivangretsky
Copy link

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.

@donho
Copy link
Member

donho commented Sep 23, 2024

@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 donho self-assigned this Sep 23, 2024
@donho donho added the accepted label Sep 23, 2024
@xomx
Copy link
Contributor

xomx commented Sep 24, 2024

@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...

@donho
Copy link
Member

donho commented Sep 26, 2024

@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.

@xomx
Copy link
Contributor

xomx commented Sep 26, 2024

@donho

If you have tried the latest status of PR

Tried with the latest commit and the only problem detected is no tab-creation date tooltip for the 1st newXXX empty tab, the others are ok:

npp-newxxx-tab-tooltip-2

However, when the periodic backup is activated, there might be a undesired behaviour:

No, it is not undesired, at least not for me:

  • when I made the tabs dirty (with the N++ backup engine ON) and waited for more than my periodic backup interval set (the N++ Preferences > Backup > "Trigger backup on modification in every XXX seconds"):

    npp-newxxx-tab-tooltip-3

  • so as soon as the time limit set for the snapshots expires and relevant backup files for the edited tabs are created, the date of the tab-tooltips will change accordingly - for me it is fine, because that tooltip date should actually rather describe when I really started editing the tab-doc than how long before my first edit the given empty tab has existed == perfect "undesired behavior" for me ;-)

@donho
Copy link
Member

donho commented Sep 26, 2024

@xomx
Thank you for testing & review.

Tried with the latest commit and the only problem detected is no tab-creation date tooltip for the 1st newXXX empty tab, the others are ok:

Fixed in the latest status of PR.

perfect "undesired behavior" for me ;-)

Nice to see that you're happy with this "feature". :)

A side note: the tip is on 2 lines without "Created date: " (in the latest commit), because it's obvious to me that users will realize what it is. Therefore we save the room & translation.

@donho donho closed this as completed in fc051a1 Sep 26, 2024
@xomx
Copy link
Contributor

xomx commented Sep 26, 2024

@donho

A side note: the tip is on 2 lines without "Created date: " (in the latest commit)

That was my last objection, I did not even have time to mention that little not-so-clear imperfection here :-)

we save the room & translation.

👍 perfect KISS in action, as always

Thanks for your time & implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants