Skip to content

WIP: Allow for pasting of image data via xclip and new macros

This MR implements insertion of arbitrary file data (and image data), proposed in issue #9. This is to be accomplished via two new macros:

  • %image:PATH%, where PATH can be a local path to the image, or a URL to an image.
  • %file:PATH%, where PATH can be a local path to the file, or a URL to the file.
    Deemed impossible to deliver (see relevant thread)

This MR will make use of xclip, and will add to the current list of dependencies. Because macros will need to be added, infrastructure from !1 (merged) will be needed.

Closes #9

To Draft

  • Allow non-text files sitting around to be chosen by the choose-snippet menu. Do this by making the outer if statement main logic check if the mimetype of the file chosen was text/*. If so, assume it's a text snippet and use the logic we already have. Otherwise, insert it as a file with the following command:
    xclip -selection clipboard -t $(mimetype -b $FILE) $FILE
  • Add new macro: %file:<path to file>%
    Deemed impossible to deliver (see relevant thread)
    • <path to file> can either be a local path or a wgettable URL.
    • if a URL, <path to file> should be downloaded in /tmp, inserted, and then removed from the drive
    • if a valid path to a file, <path to file> should be inserted in with Shift-Insert
  • Add new macro: %image:<path to image>%
    • <path to image> can either be a local path or a wgettable URL.
    • if a URL, <path to image> should be downloaded in /tmp, inserted, and then removed from the drive
    • if a valid path to an image, <path to image> should be inserted in with Shift-Insert
    • if <path to image> is a file whose mimetype isn't image/*, we should display an error

To Test

  • %image passes all test cases
    • Passes test_image_local_1 when testing with GitLab
    • Passes test_image_local_2 when testing with GitLab
    • Passes test_image_local_3 when testing with GitLab
    • Passes test_image_local_4 when testing with GitLab
    • Passes test_image_web_1 when testing with GitLab
    • Passes test_image_web_2 when testing with GitLab
    • Passes test_image_web_3 when testing with GitLab
  • %file passes all test cases
    Deemed impossible to deliver (see relevant thread)
    • Passes test_file_local_1
    • Passes test_file_local_2
    • Passes test_file_web_1
    • Passes test_file_web_2

To Document

  • Add %image and %file to the macros table in the readme
  • Add more detailed sections about %image and %file and how to use IT
    • Must mention the path can be a URL
    • Must mention the \% escapes
Edited by MyriaCore

Merge request reports

Loading