a9b301871d
Preserve passed in text rect in fTextRext (unless in layout) and create an internal version fAlignedTextRect which is used in place of fTextRect. fAlignedTextRext is aligned to fit the text rect bounds and grows to fit. fAlignedTextRect always grows vertically but only grows horizontally if wrap is off. Left-aligned text view's grow right, right-aligned ones grow left, and center center aligned ones grow out. Set fTextRect to bounds in _DoLayout(). Reduce left and right padding inside text views from full label spacing to half label spacing. Unify padding between BTextControl and BTextView. Fixing padding also fixes right and center-aligned BTextViews. Undo extra scrolling for non-left text views from hrev24130 fixing a scrolling left and right with mouse bug when it shouldn't. Replace max_c and min_c with std::max and std::min respectively. Remove scrolling from one instance of BTextView::SetText as it produced undesired results while editing a scrolled text view. Set text rect in BTextControl::DoLayout() and ScreenSaver PreviewView::AddPreview(). Don't add padding if BTextView::SetInsets() is called. Set insets to 0 in Tracker "Edit name" setting which prevents default padding from being added. This is so that when you rename a file in Tracker the TextView appears on top of the file name text with no padding. 80 char limit fixes. Fixes #1651 #12608 #13796 #15189 #15688 Change-Id: I8c6106effc612f49aff374f29742471628b5df86 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3054 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
250 lines
7.1 KiB
Python
250 lines
7.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
###
|
|
# Copyright (c) 2012, François Revol
|
|
# All rights reserved.
|
|
#
|
|
# Redistribution and use in source and binary forms, with or without
|
|
# modification, are permitted provided that the following conditions are met:
|
|
#
|
|
# * Redistributions of source code must retain the above copyright notice,
|
|
# this list of conditions, and the following disclaimer.
|
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
|
# this list of conditions, and the following disclaimer in the
|
|
# documentation and/or other materials provided with the distribution.
|
|
# * Neither the name of the author of this software nor the name of
|
|
# contributors to this software may be used to endorse or promote products
|
|
# derived from this software without specific prior written consent.
|
|
#
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
###
|
|
|
|
import supybot.conf as conf
|
|
import supybot.utils as utils
|
|
from supybot.commands import *
|
|
import supybot.callbacks as callbacks
|
|
import supybot.log as log
|
|
|
|
import random
|
|
|
|
import errors
|
|
|
|
class Haiku(callbacks.Plugin):
|
|
def __init__(self, irc):
|
|
#log.error("plop")
|
|
#print "plop"
|
|
self.fortunes = []
|
|
fortunes = open("/home/revol/devel/haiku/trunk/data/system/data/fortunes/Haiku", "r")
|
|
print fortunes
|
|
if fortunes:
|
|
fortune = ""
|
|
for line in fortunes:
|
|
if line == "%\n":
|
|
self.fortunes.append(fortune)
|
|
fortune = ""
|
|
else:
|
|
fortune += line
|
|
fortunes.close()
|
|
|
|
self.__parent = super(Haiku, self)
|
|
self.__parent.__init__(irc)
|
|
|
|
def error(self, irc, msg, args):
|
|
"""<error>
|
|
|
|
Returns the code and value for the given <error> value or code.
|
|
"""
|
|
print "Haiku: error"
|
|
print args
|
|
if not args:
|
|
raise callbacks.ArgumentError
|
|
for arg in args:
|
|
err = None
|
|
if arg in errors.errors:
|
|
err = errors.errors[arg]
|
|
key = arg
|
|
else:
|
|
try:
|
|
i = int(arg, 0)
|
|
except ValueError:
|
|
irc.errorInvalid('argument', arg, Raise=True)
|
|
for e in errors.errors:
|
|
if errors.errors[e]['value'] == i:
|
|
err = errors.errors[e]
|
|
key = e
|
|
if err is None:
|
|
irc.reply("Unknown error '%s'" % (arg))
|
|
else:
|
|
expr = err['expr']
|
|
value = err['value']
|
|
r = "%s = %s = 0x%x (%d): %s" % (key, expr, int(value), value, err['str'])
|
|
irc.reply(r)
|
|
|
|
def haiku(self, irc, msg, args):
|
|
"""
|
|
|
|
Returns a random haiku.
|
|
"""
|
|
|
|
if len(self.fortunes) > 0:
|
|
h = self.fortunes[int(random.random() * len(self.fortunes))].split('\n')
|
|
for l in h:
|
|
if l != "":
|
|
irc.reply(l, prefixNick = False)
|
|
else:
|
|
irc.reply("No haiku found")
|
|
|
|
def reportbugs(self, irc, msg, args):
|
|
"""
|
|
|
|
Returns some infos on reporting bugs.
|
|
"""
|
|
|
|
to = None
|
|
if len(args) > 0:
|
|
to = args[0]
|
|
t = "If you think there is a bug in Haiku, please report a bug so we can remember to fix it. cf. http://dev.haiku-os.org/wiki/ReportingBugs"
|
|
irc.reply(t, to = to)
|
|
|
|
def patchwanted(self, irc, msg, args):
|
|
"""
|
|
|
|
Returns some infos on submitting patches.
|
|
"""
|
|
|
|
to = None
|
|
if len(args) > 0:
|
|
to = args[0]
|
|
t = "Haiku is Free Software, therefore you can fix it yourself and send a patch, which would likely be very appreciated. cf. http://dev.haiku-os.org/wiki/SubmittingPatches"
|
|
irc.reply(t, to = to)
|
|
|
|
def download(self, irc, msg, args):
|
|
"""
|
|
|
|
Returns download links.
|
|
"""
|
|
|
|
to = None
|
|
if len(args) > 0:
|
|
to = args[0]
|
|
t = "Current release: http://www.haiku-os.org/get-haiku - Nightly builds: http://download.haiku-os.org"
|
|
irc.reply(t, to = to)
|
|
|
|
def dl(self, irc, msg, args):
|
|
"""
|
|
|
|
Returns download links.
|
|
"""
|
|
return self.download(irc, msg, args)
|
|
|
|
def vi(self, irc, msg, args):
|
|
"""
|
|
|
|
Trolls.
|
|
"""
|
|
|
|
to = None
|
|
if len(args) > 0:
|
|
to = args[0]
|
|
t = "emacs!"
|
|
irc.reply(t, to = to)
|
|
|
|
def emacs(self, irc, msg, args):
|
|
"""
|
|
|
|
Trolls.
|
|
"""
|
|
|
|
to = None
|
|
if len(args) > 0:
|
|
to = args[0]
|
|
t = "vi!"
|
|
irc.reply(t, to = to)
|
|
|
|
def bored(self, irc, msg, args):
|
|
"""
|
|
|
|
Returns some infos.
|
|
"""
|
|
|
|
to = None
|
|
if len(args) > 0:
|
|
to = args[0]
|
|
t = "Why won't you get on some easy tasks then? http://dev.haiku-os.org/wiki/EasyTasks"
|
|
irc.reply(t, to = to)
|
|
|
|
def jlg(self, irc, msg, args):
|
|
"""
|
|
|
|
Praise Jean-Louis Gassée.
|
|
"""
|
|
|
|
to = None
|
|
if len(args) > 0:
|
|
to = args[0]
|
|
t = "Jean-Louis Gassée, such a Grand Fromage!"
|
|
irc.reply(t, to = to)
|
|
|
|
def basement(self, irc, msg, args):
|
|
"""
|
|
|
|
Puts people to work.
|
|
"""
|
|
|
|
to = "everyone"
|
|
who = "them"
|
|
if len(args) > 0:
|
|
to = args[0]
|
|
who = "him"
|
|
if len(args) > 1:
|
|
to = ' and '.join([', '.join(args[:-1]), args[-1]])
|
|
who = "them"
|
|
t = "sends %s to BGA's basement and chains %s to a post in front of a computer. Get to work!" % (to, who)
|
|
irc.reply(t, action = True)
|
|
|
|
def trout(self, irc, msg, args):
|
|
"""
|
|
|
|
Puts someone back to his place.
|
|
"""
|
|
|
|
if len(args) > 0:
|
|
to = args[0]
|
|
if len(args) > 1:
|
|
to = ' and '.join([', '.join(args[:-1]), args[-1]])
|
|
t = "slaps %s with a trout." % (to)
|
|
irc.reply(t, action = True)
|
|
|
|
def plop(self, irc, msg, args):
|
|
"""
|
|
|
|
Returns some infos.
|
|
"""
|
|
|
|
to = None
|
|
if len(args) > 0:
|
|
to = args[0]
|
|
t = "plop"
|
|
irc.reply(t, to = to)
|
|
|
|
def shibboleet(self, irc, msg, args):
|
|
"""
|
|
|
|
Tech support.
|
|
"""
|
|
|
|
irc.reply("http://xkcd.com/806/ Tech Support")
|
|
|
|
Class = Haiku
|
|
|
|
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|