reference:plugins:vfs_plugins:specifying_custom_columns

Directory Opus has many built-in file information that can be displayed in Listers. Many of these can be used with VFS plugins and function automatically. Others, like the Music and Image information fields, only work with plugins if you set the appropriate capabilities flags to enable them. Other columns, like the Program information fields, do not work with VFS plugins at all.

Directory Opus lets plugins provide their own list of custom information columns that display data provided by the plugin. These columns appear to the user in the Special column category in the Folder Options dialog.

To implement custom columns you must provide a VFS_GetCustomColumns function.

BOOL VFS_GetCustomColumns( HANDLE hVFSData )

Directory Opus calls this function soon after your namespace has been instantiated with VFS_Create. The hVFSData parameter is your instance handle, returned from VFS_Create. The VFS_GetCustomColumns function must return a pointer to a linked list of VFSCUSTOMCOLUMN structures, each one of which defines a custom column.

The members of the VFSCUSTOMCOLUMN structure are:

  • UINT cbSize
    This field must contain the size of the VFSCUSTOMCOLUMN structure you are using. Directory Opus uses this to maintain backwards compatibility with older plugins.
  • LPVFSCUSTOMCOLUMN lpNext
    This member points to the next VFSCUSTOMCOLUMN structure in the chain, or 0 if this is the last column to be defined.
  • LPTSTR lpszLabel
    This field points to a null-terminated string containing the column label. This is the string that is displayed to the user in the Folder Options dialog, and in the column header in the Lister.
  • LPTSTR lpszKey
    This field points to a null-terminated string containing a keyword for your column. This is the string that the user can use in Opus raw commands in relation to this column. For example, a column whose label was Image Resolution might have the keyword imageres. Opus raw commands like Set COLUMNSADD would then accept imageres as a valid parameter. You must make sure that this keyword does not clash with any internal Opus column keywords - we recommend that you prefix your keywords with the name of your plugin to ensure they are unique (eg superplugin_imageres).
  • DWORD dwFlags
    This member lets you specify flags that control how the column data is displayed to the user. Currently defined flags are:
    • VFSCCF_LEFTJUSTIFY
      The column data is to be left-justified. This is the default.
    • VFSCCF_RIGHTJUSTIFY
      The column data is to be right-justified.
    • VFSCCF_CENTERJUSTIFY
      The column data is to be center-justified.
    • VFSCCF_NUMBER
      The column data is to be formatted as a number. Even though column data is always provided as a string, Opus will treat the contents as a number and format it using the current user's locale settings. This flag also ensures that numeric columns are sorted in correct numerical order.
    • VFSCCF_PERCENT
      The column data is to be formatted as a percentage. Currently this simply entails displaying the supplied string with a trailing percent sign. This flag also ensures that the column will be sorted in correct numerical order.
    • VFSCCF_SIZE
      The column data is to be formatted as a file size. The value you provide for the column data is assumed to be a number of bytes, and will be displayed to the user as either a byte value, a rounded-up kilobyte value, or an automatic value depending on the user's Preferences settings. This flag also ensures that the column will be sorted in correct numerical order.
  • int iID
    This field is an ID code that your plugin will use when setting the column data of files in your plugin's namespace. You should give each column a unique ID, numbered sequentially and beginning from 1.

The column information you return from the VFS_GetCustomColumns function must remain valid for at least the lifetime of the namespace instance. Opus treats the pointer you return as read-only - it will not modify it or any of the data it points to but it may use the data and strings at any time. Therefore you should either define your columns as static data, or allocate the data when your namespace is instantiated and only free it when your namespace is destroyed.

If your plugin does not require custom columns you should simply not provide a VFS_GetCustomColumns function.