GE Lua Documentation

Press F to search!

HighlightText

Definition


-- @/lua/common/extensions/ui/imgui_custom_luaintf.lua:309
  function M.HighlightText(label, highlightText)
    M.PushStyleVar2(M.StyleVar_ItemSpacing, M.ImVec2(0, 0))
    if highlightText == "" then
      M.TextColored(matchColor,label)
    else
      local pos1 = 1
      local pos2 = 0
      local labelLower = label:lower()
      local highlightLower = highlightText:lower()
      local highlightLowerLen = string.len(highlightLower) - 1
      for i = 0, 6 do -- up to 6 matches overall ...
        pos2 = labelLower:find(highlightLower, pos1, true)
        if not pos2 then
          M.Text(label:sub(pos1))
          break
        elseif pos1 < pos2 then
          M.Text(label:sub(pos1, pos2 - 1))
          M.SameLine()
        end

        local pos3 = pos2 + highlightLowerLen
        M.TextColored(matchColor, label:sub(pos2, pos3))
        M.SameLine()
        pos1 = pos3 + 1
      end
    end
    M.PopStyleVar()
  end

Callers

@/lua/common/extensions/ui/imgui_custom_luaintf.lua
    local x = M.GetCursorPosX()
    M.HighlightText(label, highlightText)
    local spacing = M.GetStyle().ItemSpacing
@/lua/common/extensions/ui/flowgraph/editor.lua
        local cPos = im.GetCursorScreenPos()
        im.HighlightText(result.name, vehSearch.matchString)
        im.SameLine()
        im.BeginDisabled()
        im.HighlightText(result.info.modelKey .. "/"..result.info.configKey, vehSearch.matchString)
        im.EndDisabled()
@/lua/ge/extensions/editor/perfProfiler.lua
        im.SameLine()
        im.HighlightText(result.name, search.matchString)
        im.EndChild()