Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [Solved] Trigger proper highlighting for files - seems impossible
Forum Updated to NodeBB v4.3 + New Features

[Solved] Trigger proper highlighting for files - seems impossible

Scheduled Pinned Locked Moved Qt Creator and other tools
4 Posts 2 Posters 2.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cefn
    wrote on last edited by
    #1

    I'm on Ubuntu, trying to edit /usr/bin/ecryptfs-setup-swap

    Can anyone tell me how I can persuade Qt Creator to load this shell script file with the proper highlighting? I'm astonished at the massive fail in my first attempt to use the editor, and can't believe it's really that broken. It must be me, but I can't figure it out.

    Opening the file notifies you that there's no highlighting been triggered, and helpfully invites you to visit a configuration pane (Tools>Options>Text Editor>Generic Highlighter) which can do nothing about it, which is frankly bizarre. I was expecting to be able to choose one of the highlighting schemes and deal with it manually, but this is not provided.

    From trying many different things, I've come to the conclusion that it's actually impossible to associate the proper highlighting because of the series of counterintuitive interfaces and broken assumptions built into the highlighting UI, in particular; i) a fixed list of MIME types, ii) the assumption that file suffixes will indicate file type and iii) the absence of an association between MIME type and Kate highlighting config in the UI

    On my system...

    $ file --mime /usr/bin/ecryptfs-setup-swap
    /usr/bin/ecryptfs-setup-swap: text/x-shellscript; charset=us-ascii

    ...but Qt Creator only acknowledges a MIME type of application/x-shellscript not text/x-shellscript and it's impossible to edit its list of MIME types.

    So in summary, the Bash highlighting rules seem to be downloaded and visible in the highlighting config directory, but there's no configuration either on a global or a per-editor-pane basis which seems to associate that highlighting logic with the file /usr/bin/ecryptfs-setup-swap

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cefn
      wrote on last edited by
      #2

      OK, instantly I post it I find a solution. It seems that the checkbox "Use fallback location" needs to be unchecked to get the downloaded Kate files in the configured /home/user/.config/Nokia/qtcreator/generic-highlighter to be considered.

      When have "Use fallback location" selected, it doesn't mean that it will use the location as a fallback (when a match isn't found).

      Instead, it's just a second box which you can type a path in, and the checkbox means "use this path instead". In my case, so long as this was checked, highlighting was non-functional.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mlong
        wrote on last edited by
        #3

        Glad you found a solution. Be sure and mark your post as [Solved] by editing the thread title. Thanks!

        Software Engineer
        My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

        1 Reply Last reply
        0
        • C Offline
          C Offline
          cefn
          wrote on last edited by
          #4

          I should provide a little more detail for others struggling with similar issues. The workaround I adopted was to add a "magic header" entry to the MIME type application/x-shellscript within the Tools>Options>Environment>MIME Types so that wherever...

          #!/bin/sh

          ...appears in the first few characters of a file, then Qt Creator considers the file to be application/x-shellscript.

          N.B. as detailed in the previous post, if you leave "Use fallback location" selected, then highlighting fails, and there's no way to manually associate a file with a highlighting scheme to get over these issues in automated loading.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved