From c1f0972dec52f0d0ff2352e2125be46fa9362ffc Mon Sep 17 00:00:00 2001 From: James Whitehead II Date: Mon, 28 Apr 2008 22:34:10 +0000 Subject: [PATCH] Fixed issues with line numbering --- FAIAP.lua | 6 +++++- WowLua.lua | 66 ++++++++++++++++++++++++++++++++++++++++++------------------ WowLua.xml | 9 +++++++++ 3 files changed, 60 insertions(+), 21 deletions(-) diff --git a/FAIAP.lua b/FAIAP.lua index c9a82c0..356299e 100755 --- a/FAIAP.lua +++ b/FAIAP.lua @@ -1103,7 +1103,11 @@ local function onUpdateHook(editbox, ...) end end -local function newGetText(editbox) +local function newGetText(editbox, raw) + if raw then + return lib.decode(editboxGetText(editbox)) + end + local decoded = decodeCache[editbox] if not decoded then decoded = lib.decode(editboxGetText(editbox)) diff --git a/WowLua.lua b/WowLua.lua index f5b4dcf..3daaee2 100644 --- a/WowLua.lua +++ b/WowLua.lua @@ -320,7 +320,7 @@ end local function slashHandler(txt) local page = WowLuaDB.pages[WowLuaDB.currentPage] - WowLuaFrameEditBox:SetText(WowLuaDB.pages[page]) + WowLuaFrameEditBox:SetText(WowLuaDB.pages[page] or "") if WowLuaDB.currentPage == 1 then WowLuaButton_Previous:Disable() SetDesaturation(WowLuaButton_Previous:GetNormalTexture(),true) @@ -495,33 +495,51 @@ function WowLua.OnVerticalScroll(scrollFrame) end function WowLua.UpdateLineNums(highlightNum) - local text = WowLuaFrameEditBox:GetText() + -- highlightNum is the line number indicated by the error message - highlightNum = highlightNum or WowLuaFrameEditBox.highlightNum + -- Since we know this is FAIAP enabled, we need to pass true in order + -- to get the raw values + local editbox = WowLuaFrameEditBox + local linebox = WowLuaFrameLineNumEditBox + local linetest = WowLuaFrameEditBoxLineTest + local linescroll = WowLuaFrameLineNumScrollFrame - local lineText = "" + local width = editbox:GetWidth() + local text = editbox:GetText(true) + + local linetext = "" local count = 1 + for line in text:gmatch("([^\n]*\n?)") do + if #line > 0 then + if count == highlightNum then + linetext = linetext .. "|cffff2222" .. count .. "|r\n" + else + linetext = linetext .. count .. "\n" + end + count = count + 1 - if count == highlightNum then - lineText = lineText .. "|cFFFF1111" .. count .. "|r" .. "\n" - else - lineText = lineText .. count .. "\n" + -- Check to see if the line of text spans more than one actual line + linetest:SetText(line:gsub("|", "||")) + local testwidth = linetest:GetWidth() + if testwidth >= width then + linetext = linetext .. string.rep("\n", testwidth / width) + end + end end - count = count + 1 - - for line in WowLuaFrameEditBox:GetText():gmatch("\n") do - if count == highlightNum then - lineText = lineText .. "|cFFFF1111" .. count .. "|r" .. "\n" - else - lineText = lineText .. count .. "\n" - end - + if text:sub(-1, -1) == "\n" then + linetext = linetext .. count .. "\n" count = count + 1 end - WowLuaFrameLineNumEditBox:SetText(lineText) - WowLuaFrameEditBox.oldtext = text - WowLuaFrameEditBox.highlightNum = highlightNum + + -- Make the line number frame wider as necessary + local offset = tostring(count):len() * 10 + linescroll:ClearAllPoints() + linescroll:SetPoint("TOPLEFT", WowLuaFrame, "TOPLEFT", 18, -74) + linescroll:SetPoint("BOTTOMRIGHT", WowLuaFrameResizeBar, "TOPLEFT", 15 + offset, -4) + + linebox:SetText(linetext) + linetest:SetText(text) end local function canScroll(scroll, direction) @@ -583,3 +601,11 @@ function WowLua.ScrollingMessageFrameScroll(scroll, direction, type) scroll[method](scroll); end +function WowLua.OnTextChanged(self) + self.highlightNum = nil +end + +function WowLua.OnCursorChanged(self) + WowLua.dirty = true +end + diff --git a/WowLua.xml b/WowLua.xml index 070f770..d717bc7 100644 --- a/WowLua.xml +++ b/WowLua.xml @@ -422,6 +422,15 @@ + + + + + -- 1.7.9.5