[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Miniwindows
. . -> [Subject]  Setting Miniwindows to Scroll?

Setting Miniwindows to Scroll?

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Pages: 1  2 

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #15 on Sun 19 Apr 2009 11:15 AM (UTC)
Message
You can certainly have multiple miniwindows in a plugin, as Worstje says, make sure you give them names that are likely to be unique. For example in one of my plugins:


win = GetPluginID ()  -- get a unique name
tempwin = win .. ":temp"


This gives me two names for miniwindows - the first is the plugin ID which should be unique, and the second one appends ":temp" to give a variation on that name, which also should be unique amongst other plugins.

So if you wanted four windows you could do something like this:


win1 = GetPluginID ()  .. ":1"
win2 = GetPluginID ()  .. ":2"
win3 = GetPluginID ()  .. ":3"
win4 = GetPluginID ()  .. ":4"


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Hoax   (14 posts)  [Biography] bio
Date Reply #16 on Thu 23 Apr 2009 07:46 AM (UTC)
Message
I'm not sure if the script above already implement this idea I have. At work, and reading too much gives me headache atm. :)

But what you can do is, add 2 more buttons, which moves up/down several line, or even a page. Just like the arrow and double arrow button you find in tape/cd/etc player.

Cheers.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #17 on Thu 23 Apr 2009 10:47 AM (UTC)
Message
I wouldn't use multiple miniwindows just to add buttons - that is what hotspots are for. Draw a button on your main window, and make that button rectangle a hotspot. Then when you click on it you can change its colour, play a "click" sound, and do something useful.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Hoax   (14 posts)  [Biography] bio
Date Reply #18 on Fri 24 Apr 2009 07:24 AM (UTC)
Message
Sorry, I should've said hotspot, rather than button. And maybe add 2 more hotspot on top of the 4. Starting with a 'top' hotspot at the right-top hand corner, that scrolls to the top. Then a hotspot below it, for scrolling up 1 page. Then another one below it for scrolling per line. And so on.

That way, you don't have to break the mouse just to move to the top of the page. ;)

Cheers.
[Go to top] top

Posted by Garrion   (21 posts)  [Biography] bio
Date Reply #19 on Fri 24 Jul 2009 11:13 PM (UTC)
Message
I have been trying to combine the different advice in this thread into one plugin.

I have a capture miniwindow that scrolls but I am having trouble adding in the ability for the text to wrap. I have tried several times but I keep failing as I am still very new to this.

Below is my working plugin. Any help to get text to wrap would be appreciated.


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<!-- This plugin was made using all the code and ideas at http://www.gammon.com.au/forum/?id=9385 -->

<muclient>
<plugin
   name="ChatWindow"
   author="Garrion"
   id="4de91eaa2624f202c4bb6835"
   language="Lua"
   purpose="Move chats to a miniwindow"
   date_written="2009-07-23"
   requires="4.40"
   version="1.0"
   >

</plugin>

<triggers>
  <trigger
   enabled="y"
   ignore_case="y"
   match="(^)(\(pishe\)|\(thieves\)|\(wizards\)|\(warriors\)|\(witches\)|\(assassins\)|\(RRU\)|\(newbiehelpers\)|\(newbie\)) (.*)$"
   regexp="y"
   script="chats"
   sequence="60"
  >
  </trigger>
</triggers>

<!--  Aliases  -->


<aliases>

</aliases>

<!--  Script  -->


<script>
<![CDATA[
  
  -- configuration

  -- window size in pixels
WINDOW_WIDTH = GetInfo (281)
WINDOW_HEIGHT = 200   -- 200 is 16 lines of 9-point Lucida Console
SCROLL_BAR_WIDTH = 18
LEFT_MARGIN = 5
RIGHT_MARGIN = 5

  -- font
FONT_NAME = "Lucida Console"
FONT_SIZE = 9

  -- where to put the window
WINDOW_POSITION = 6  -- see below (6 is top right)

  --[[
Useful positions:

4 = top left
5 = center left-right at top
6 = top right
7 = on right, center top-bottom
8 = on right, at bottom
9 = center left-right at bottom
  --]]


  -- colours
WINDOW_BACKGROUND_COLOUR = ColourNameToRGB ("black")
WINDOW_TEXT_COLOUR = ColourNameToRGB ("silver")
SCROLL_BACKGROUND_COLOUR = ColourNameToRGB ("#E8E8E8")
SCROLL_BAR_COLOUR = ColourNameToRGB ("#C8C8C8")

text = {}

lineStart = 1
lineEnd = 1
SBWin = "ScrollbarWindow"..GetPluginID()

function OnPluginInstall()
	init()
end

function init()
	WindowCreate(SBWin, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_POSITION, 0, WINDOW_BACKGROUND_COLOUR)
	WindowAddHotspot(SBWin, "upHotspot", WINDOW_WIDTH-SCROLL_BAR_WIDTH, 0, 0, 20, "MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "Scroll up?", 1, 0)
	WindowAddHotspot(SBWin, "downHotspot", WINDOW_WIDTH-SCROLL_BAR_WIDTH, WINDOW_HEIGHT-20, 0, 0, "MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "Scroll down?", 1, 0)
  WindowShow(SBWin, true)

		-- show border so we can see what we are doing
  WindowRectOp (SBWin, 1, 0, 0, 0, 0, SCROLL_BACKGROUND_COLOUR)
  
  	-- show bar and slider
	WindowRectOp(SBWin, 2, WINDOW_WIDTH-SCROLL_BAR_WIDTH, 0, 0, 0, SCROLL_BACKGROUND_COLOUR)
	WindowRectOp (SBWin, 1, WINDOW_WIDTH-SCROLL_BAR_WIDTH+1, 20, WINDOW_WIDTH-1, WINDOW_HEIGHT-20, SCROLL_BAR_COLOUR)
	
	if #text >= 1 then
    writeLines()
  end -- if
end

function writeLines()
	SPACING = 1
	for count = lineStart, lineEnd do
		WindowText(SBWin, "font"..SBWin, text[count], LEFT_MARGIN, SPACING, WINDOW_WIDTH-(RIGHT_MARGIN+SCROLL_BAR_WIDTH), 0, WINDOW_TEXT_COLOUR, false)
    SPACING = SPACING + (font_height + 1)
	end
end

function refresh()
	WindowRectOp(SBWin, 2, 0, 0, 0, 0, WINDOW_BACKGROUND_COLOUR)
	WindowShow(SBWin, true)
  init()
end

  -- capture chats
function chats (name, line, wildcards, styles)

    -- add new line, time-stamped
  table.insert (text, os.date ("%H:%M:%S ") .. line) -- add new line, time-stamped
  
    -- advance the count
  if #text >= max_lines then
    lineStart = lineStart + 1
  end -- if
  
  if #text > 1 then
  	lineEnd = lineEnd + 1
  end -- if
	
  refresh()
end -- chats

function scrollbar(calledBy)
	if calledBy == "upHotspot" then
		if (lineStart > 1) then
			lineStart = lineStart - 1
			lineEnd = lineEnd - 1
		end
	elseif calledBy == "downHotspot" then
		if (lineEnd < #text) then
			lineStart = lineStart + 1
			lineEnd = lineEnd + 1
		end
	end
	refresh()
end

function MouseOver(flags, hotspot_id)
end

function CancelMouseOver(flags, hotspot_id)
end

function MouseDown(flags, hotspot_id)
end

function CancelMouseDown(flags, hotspot_id)
end

function MouseUp(flags, hotspot_id)
	scrollbar(hotspot_id)
end

-- make the window
WindowCreate (SBWin, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_POSITION, 0, 
                         WINDOW_BACKGROUND_COLOUR)  -- create window

  -- define font
WindowFont(SBWin, "font"..SBWin, FONT_NAME, FONT_SIZE)

  -- work out how high it is
font_height = WindowFontInfo (SBWin, "font"..SBWin, 1)  

  -- work out how many lines will fit
max_lines = math.floor (WINDOW_HEIGHT / font_height)

]]>
</script>

</muclient>
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #20 on Fri 24 Jul 2009 11:57 PM (UTC)
Message
See this thread:

http://www.gammon.com.au/forum/?id=9454

In particular, near the bottom was a small bit of code that wrapped output by breaking up "line" at the wrap_column, at the nearest space. It then called add_line to actually output the line. A variation on that should do it for you.



-- wrap long lines, at a space if possible
  while #line > wrap_column do
  
    -- find a space not followed by a space, closest to the end of the line
    local col = string.find (line:sub (1, wrap_column), "%s%S*$")
    
    if col and col > 2 then
      col = col - 1  -- use the space to indent
    else
      col = wrap_column  -- just cut off at wrap_column
    end -- if

    add_line (line:sub (1, col))
    line = line:sub (col + 1) 
    
  end -- while line > max



- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Garrion   (21 posts)  [Biography] bio
Date Reply #21 on Sun 26 Jul 2009 01:29 AM (UTC)

Amended on Sun 26 Jul 2009 01:35 AM (UTC) by Garrion

Message
Thanks Nick.

I made some adjustments based on that thread and it works to a degree. It will wrap 1 line ok but if it has to wrap on the second line it starts to double up (example below).

Can anyone help to explain what I have done wrong please?

Example of double output:

(Pishe) Garrion: You are in a clean, airy room, with large
 windows overlooking the street outside. A high counter almost
 windows overlooking the street outside. A high counter
 almost completely separates the far half of the room.


Revised plugin in next post.
[Go to top] top

Posted by Garrion   (21 posts)  [Biography] bio
Date Reply #22 on Sun 26 Jul 2009 01:30 AM (UTC)
Message

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<!-- This plugin was made using all the code and ideas at http://www.gammon.com.au/forum/?id=9385 -->

<muclient>
<plugin
   name="ChatWindow"
   author="Garrion"
   id="4de91eaa2624f202c4bb6835"
   language="Lua"
   purpose="Move chats to a miniwindow"
   date_written="2009-07-23"
   requires="4.40"
   version="1.0"
   >

</plugin>

<triggers>
  <trigger
   enabled="y"
   ignore_case="y"
   match="(^)(\(number chasers\)|\(pishe\)|\(thieves\)|\(wizards\)|\(warriors\)|\(witches\)|\(assassins\)|\(RRU\)|\(newbiehelpers\)|\(newbie\)) (.*)$"
   regexp="y"
   script="chats"
   sequence="60"
  >
  </trigger>
  
    <trigger
   custom_colour="2"
   enabled="y"
   ignore_case="y"
   match="(^)you (newbie-tell|newbiehelpers-tell)(.*)(\:)(.*)"
   regexp="y"
   script="chats"
   sequence="60"
  >
  </trigger>
</triggers>

<!--  Aliases  -->


<aliases>

</aliases>

<!--  Script  -->


<script>
<![CDATA[
  
  -- configuration

  -- window size in pixels
WINDOW_WIDTH = GetInfo (281)
WINDOW_HEIGHT = 200   -- 200 is 16 lines of 9-point Lucida Console
SCROLL_BAR_WIDTH = 18
LEFT_MARGIN = 5
RIGHT_MARGIN = 5

  -- font
FONT_NAME = "Lucida Console"
FONT_SIZE = 9

  -- where to put the window
WINDOW_POSITION = 6  -- see below (6 is top right)

  --[[
Useful positions:

4 = top left
5 = center left-right at top
6 = top right
7 = on right, center top-bottom
8 = on right, at bottom
9 = center left-right at bottom
  --]]


  -- colours
WINDOW_BACKGROUND_COLOUR = ColourNameToRGB ("black")
WINDOW_TEXT_COLOUR = ColourNameToRGB ("silver")
SCROLL_BACKGROUND_COLOUR = ColourNameToRGB ("#E8E8E8")
SCROLL_BAR_COLOUR = ColourNameToRGB ("#C8C8C8")

text = {}

lineStart = 1
lineEnd = 1
SBWin = "ScrollbarWindow"..GetPluginID()

function OnPluginInstall()
	init()
	Note (wrap_column)
end

function init()
	WindowCreate(SBWin, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_POSITION, 0, WINDOW_BACKGROUND_COLOUR)
	WindowAddHotspot(SBWin, "upHotspot", WINDOW_WIDTH-SCROLL_BAR_WIDTH, 0, 0, 20, "MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "Scroll up?", 1, 0)
	WindowAddHotspot(SBWin, "downHotspot", WINDOW_WIDTH-SCROLL_BAR_WIDTH, WINDOW_HEIGHT-20, 0, 0, "MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "Scroll down?", 1, 0)
  WindowShow(SBWin, true)

		-- show border so we can see what we are doing
  WindowRectOp (SBWin, 1, 0, 0, 0, 0, SCROLL_BACKGROUND_COLOUR)
  
  	-- show bar and slider
	WindowRectOp(SBWin, 2, WINDOW_WIDTH-SCROLL_BAR_WIDTH, 0, 0, 0, SCROLL_BACKGROUND_COLOUR)
	WindowRectOp (SBWin, 1, WINDOW_WIDTH-SCROLL_BAR_WIDTH+1, 20, WINDOW_WIDTH-1, WINDOW_HEIGHT-20, SCROLL_BAR_COLOUR)
	
	if #text >= 1 then
    writeLines()
  end -- if
end

function writeLines()
	SPACING = 1
	for count = lineStart, lineEnd do
		WindowText(SBWin, "font"..SBWin, text[count], LEFT_MARGIN, SPACING, WINDOW_WIDTH-(RIGHT_MARGIN+SCROLL_BAR_WIDTH), 0, WINDOW_TEXT_COLOUR, false)
    SPACING = SPACING + (font_height + 1)
	end
end

function refresh()
	WindowRectOp(SBWin, 2, 0, 0, 0, 0, WINDOW_BACKGROUND_COLOUR)
	WindowShow(SBWin, true)
  init()
end

  -- capture chats
function chats (name, line, wildcards, styles)

  if #line < wrap_column then
    add_line (line)
    refresh()
  end -- if

  -- wrap long lines, at a space if possible
  --if #text >= 1 then
    while #line > wrap_column do
    
      -- find a space not followed by a space, closest to the end of the line
      local col = string.find (line:sub (1, wrap_column), "%s%S*$")
      
      if col and col > 2 then
        col = col - 1  -- use the space to indent
      else
        col = wrap_column  -- just cut off at wrap_column
      end -- if

      add_line (line:sub (1, col))
      line = line:sub (col + 1) 
      
        -- add remainder of line
      add_line (line)
      
      refresh()
    end -- while line > max
  --end -- if
end -- chats

function add_line (line)

  -- add new line
  table.insert (text, line)
  
  -- advance the count
  if #text >= max_lines then
    lineStart = lineStart + 1
  end -- if
      
  if #text > 1 then
    lineEnd = lineEnd + 1
  end -- if
end -- add_line


function scrollbar(calledBy)
	if calledBy == "upHotspot" then
		if (lineStart > 1) then
			lineStart = lineStart - 1
			lineEnd = lineEnd - 1
		end
	elseif calledBy == "downHotspot" then
		if (lineEnd < #text) then
			lineStart = lineStart + 1
			lineEnd = lineEnd + 1
		end
	end
	refresh()
end

function MouseOver(flags, hotspot_id)
end

function CancelMouseOver(flags, hotspot_id)
end

function MouseDown(flags, hotspot_id)
end

function CancelMouseDown(flags, hotspot_id)
end

function MouseUp(flags, hotspot_id)
	scrollbar(hotspot_id)
end

-- make the window
WindowCreate (SBWin, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_POSITION, 0, 
                         WINDOW_BACKGROUND_COLOUR)  -- create window

  -- define font
WindowFont(SBWin, "font"..SBWin, FONT_NAME, FONT_SIZE)

  -- work out how high it is
font_height = WindowFontInfo (SBWin, "font"..SBWin, 1)  

  -- work out how many lines will fit
max_lines = math.floor (WINDOW_HEIGHT / font_height)

COLUMN = WindowTextWidth (SBWin, "font"..SBWin, " ")

wrap_column = ((WINDOW_WIDTH-SCROLL_BAR_WIDTH)-(RIGHT_MARGIN+LEFT_MARGIN))/COLUMN
]]>
</script>

</muclient>
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #23 on Sun 26 Jul 2009 03:28 AM (UTC)
Message
You've changed what I had to:


      add_line (line:sub (1, col))
      line = line:sub (col + 1) 
      
        -- add remainder of line
      add_line (line)


Won't that second add_line add the remainder of the line, giving the results you are seeing?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Garrion   (21 posts)  [Biography] bio
Date Reply #24 on Sun 26 Jul 2009 08:18 AM (UTC)
Message
Ahh yes.

I added that after looking at the linked thread. Without it the last line that is only a partial line does not get shown.

I just tested it and that is the part causing the double line. I will have to figure out how to show the last partial line now.

Thanks Nick.
[Go to top] top

Posted by Illusaen   (2 posts)  [Biography] bio
Date Reply #25 on Sun 30 Aug 2009 08:25 AM (UTC)
Message
I copy/pasted Garrion's code and tried to make it work on Materia Magica, but I'm having problems making the word wrapping work. Instead of wrapping a line, it's cutting the line off. The changes I've made to Garrion's original code are:
1. Pattern match on trigger.
2. WINDOW_HEIGHT and WINDOW_WIDTH
3. WINDOW_POSITION
I'm pretty sure none of those changes would cause a problem; however, I'll post the code below as I have it now as well. Thanks in advance for the help!
[Go to top] top

Posted by Illusaen   (2 posts)  [Biography] bio
Date Reply #26 on Sun 30 Aug 2009 08:26 AM (UTC)
Message
The code:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<!-- This plugin was made using all the code and ideas at http://www.gammon.com.au/forum/?id=9385 -->

<muclient>
<plugin
   name="ChatWindow"
   author="Garrion"
   id="4de91eaa2624f202c4bb6835"
   language="Lua"
   purpose="Move chats to a miniwindow"
   date_written="2009-07-23"
   requires="4.40"
   version="1.0"
   >

</plugin>

<triggers>
  <trigger
   enabled="y"
   ignore_case="y"
   match="(^)[CLAN] (.*)$"
   regexp="y"
   script="chats"
   sequence="60"
  >
  </trigger>
  <trigger
   enabled="y"
   ignore_case="y"
   match="(^)\'(.*)\' you say\.$"
   regexp="y"
   script="chats"
   sequence="60"
  >
  </trigger>
  <trigger
   enabled="y"
   ignore_case="y"
   match="(^)You say\, (.*)$"
   regexp="y"
   script="chats"
   sequence="60"
  >
  </trigger>

    <trigger
   custom_colour="2"
   enabled="y"
   ignore_case="y"
   match="(^)[(\d+)] (clan members heard you say\, \')(.*)\'"
   regexp="y"
   script="chats"
   sequence="60"
  >
  </trigger>
</triggers>

<!--  Aliases  -->


<aliases>

</aliases>

<!--  Script  -->


<script>
<![CDATA[
  
  -- configuration

  -- window size in pixels
--WINDOW_WIDTH = GetInfo (281)
--WINDOW_HEIGHT = 200   -- 200 is 16 lines of 9-point Lucida Console
WINDOW_WIDTH = 400
WINDOW_HEIGHT = GetInfo (280) - 40
SCROLL_BAR_WIDTH = 18
LEFT_MARGIN = 5
RIGHT_MARGIN = 5

  -- font
FONT_NAME = "Lucida Console"
FONT_SIZE = 9

  -- where to put the window
WINDOW_POSITION = 7  -- see below (6 is top right)

  --[[
Useful positions:

4 = top left
5 = center left-right at top
6 = top right
7 = on right, center top-bottom
8 = on right, at bottom
9 = center left-right at bottom
  --]]


  -- colours
WINDOW_BACKGROUND_COLOUR = ColourNameToRGB ("black")
WINDOW_TEXT_COLOUR = ColourNameToRGB ("silver")
SCROLL_BACKGROUND_COLOUR = ColourNameToRGB ("#E8E8E8")
SCROLL_BAR_COLOUR = ColourNameToRGB ("#C8C8C8")

text = {}

lineStart = 1
lineEnd = 1
SBWin = "ScrollbarWindow"..GetPluginID()

function OnPluginInstall()
	init()
	Note (wrap_column)
end

function init()
	WindowCreate(SBWin, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_POSITION, 0, WINDOW_BACKGROUND_COLOUR)
	WindowAddHotspot(SBWin, "upHotspot", WINDOW_WIDTH-SCROLL_BAR_WIDTH, 0, 0, 20, "MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "Scroll up?", 1, 0)
	WindowAddHotspot(SBWin, "downHotspot", WINDOW_WIDTH-SCROLL_BAR_WIDTH, WINDOW_HEIGHT-20, 0, 0, "MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "Scroll down?", 1, 0)
  WindowShow(SBWin, true)

		-- show border so we can see what we are doing
  WindowRectOp (SBWin, 1, 0, 0, 0, 0, WINDOW_BACKGROUND_COLOUR)
  
  	-- show bar and slider
	WindowRectOp(SBWin, 2, WINDOW_WIDTH-SCROLL_BAR_WIDTH, 0, 0, 0, SCROLL_BACKGROUND_COLOUR)
	WindowRectOp (SBWin, 1, WINDOW_WIDTH-SCROLL_BAR_WIDTH+1, 20, WINDOW_WIDTH-1, WINDOW_HEIGHT-20, SCROLL_BAR_COLOUR)
	
	if #text >= 1 then
    writeLines()
  end -- if
end

function writeLines()
	SPACING = 1
	for count = lineStart, lineEnd do
		WindowText(SBWin, "font"..SBWin, text[count], LEFT_MARGIN, SPACING, WINDOW_WIDTH-(RIGHT_MARGIN+SCROLL_BAR_WIDTH), 0, WINDOW_TEXT_COLOUR, false)
    SPACING = SPACING + (font_height + 1)
	end
end

function refresh()
	WindowRectOp(SBWin, 2, 0, 0, 0, 0, WINDOW_BACKGROUND_COLOUR)
	WindowShow(SBWin, true)
  init()
end

  -- capture chats
function chats (name, line, wildcards, styles)

  if #line < wrap_column then
    add_line (line)
    refresh()
  end -- if

  -- wrap long lines, at a space if possible
  if #text >= 1 then
    while #line > wrap_column do
    
      -- find a space not followed by a space, closest to the end of the line
      local col = string.find (line:sub (1, wrap_column), "%s%S*$")
      
      if col and col > 2 then
        col = col - 1  -- use the space to indent
      else
        col = wrap_column  -- just cut off at wrap_column
      end -- if

      add_line (line:sub (1, col))
      line = line:sub (col + 1, wrap_column)
      
      refresh()
    end -- while line > max
   end -- if
end -- chats

function add_line (line)

  -- add new line
  table.insert (text, line)
  
  -- advance the count
  if #text >= max_lines then
    lineStart = lineStart + 1
  end -- if
      
  if #text > 1 then
    lineEnd = lineEnd + 1
  end -- if
end -- add_line


function scrollbar(calledBy)
	if calledBy == "upHotspot" then
		if (lineStart > 1) then
			lineStart = lineStart - 1
			lineEnd = lineEnd - 1
		end
	elseif calledBy == "downHotspot" then
		if (lineEnd < #text) then
			lineStart = lineStart + 1
			lineEnd = lineEnd + 1
		end
	end
	refresh()
end

function MouseOver(flags, hotspot_id)
end

function CancelMouseOver(flags, hotspot_id)
end

function MouseDown(flags, hotspot_id)
end

function CancelMouseDown(flags, hotspot_id)
end

function MouseUp(flags, hotspot_id)
	scrollbar(hotspot_id)
end

-- make the window
WindowCreate (SBWin, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_POSITION, 0, 
                         WINDOW_BACKGROUND_COLOUR)  -- create window

  -- define font
WindowFont(SBWin, "font"..SBWin, FONT_NAME, FONT_SIZE)

  -- work out how high it is
font_height = WindowFontInfo (SBWin, "font"..SBWin, 1)  

  -- work out how many lines will fit
max_lines = math.floor (WINDOW_HEIGHT / font_height)

COLUMN = WindowTextWidth (SBWin, "font"..SBWin, " ")

wrap_column = ((WINDOW_WIDTH-SCROLL_BAR_WIDTH)-(RIGHT_MARGIN+LEFT_MARGIN))/COLUMN
]]>
</script>

</muclient>
[Go to top] top

Posted by Marcopolo   (3 posts)  [Biography] bio
Date Reply #27 on Mon 31 Aug 2009 09:46 AM (UTC)
Message
I may have fixed Garrion's issue by putting #line into a variable and doing a check in order to use addline(line) at the end.

Something like this:

function chats ..
myline = #line

while ..
..
end

if myline > wrap_column then
    add_line (line)
   end
refresh()

end
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


70,454 views.

This is page 2, subject is 2 pages long:  [Previous page]  1  2 

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]