Author Topic: HKTools 0.20 (IP, TS3, MIRANDA, foobar2000)  (Read 19014 times)

SirReal

  • Administrator
  • Hero Member
  • *****
  • Posts: 735
    • linkdata.se
Re: HKTools 0.20 (IP, TS3, MIRANDA, foobar2000)
« Reply #15 on: 2011-01-11 20:38:46 »
Well, the ICU library is way too large.
Just plain local 8 bit text -> UTF8 and the reverse is trivial to provide, but I figure you need more.
UTF8 string length I suppose. What else?

lethys

  • Moderator
  • Jr. Member
  • *****
  • Posts: 78
Re: HKTools 0.20 (IP, TS3, MIRANDA, foobar2000)
« Reply #16 on: 2011-01-11 21:53:44 »
icu.ustring.encode, .decode, .length, .sub, .gsub, .find, icu.regex.compile, .split, .replace, .match
those are the functions i use as far as I can see from a quick search in the code. the icu.regex library is excellent and fills a need that arises from luas minimal implementation :/ although I could probably do something like "^(.+)([\\d]{2}:[\\d]{2}:[\\d]{2})(.+)" with luas normal regex but it seemed kind of weird to me completely unlike sed or the implementation in notepad++ while icu.regex is pretty much the same and very comprehensive

SirReal

  • Administrator
  • Hero Member
  • *****
  • Posts: 735
    • linkdata.se
Re: HKTools 0.20 (IP, TS3, MIRANDA, foobar2000)
« Reply #17 on: 2011-01-14 16:46:49 »
Rather than me mucking about with reinventing the wheel, see if these are usable:

https://github.com/mkottman/lqt

Click on "Downloads", he has prebuilt binaries for Qt 4.7 there. Not 4.7.1 tho, but they should be ABI compatible.
I'll be testing myself, and if they work OK I'll ship some of them with LCDHost.

Note that any GUI calls from Lua will fail, since only the main thread may do GUI calls with Qt.
The following libs *should* be mostly safe though:
qtcore.dll
qtnetwork.dll
qtxml.dll
qtxmlpatterns.dll

QtCore especially should be interesting to you, as that binds QString with it's excellent conversion methods and QRegEx.

Come to think of it, if these bindings are of high enough quality, perhaps QImage and QPainter is a better bet than Cairo for rendering.
Those would be in qtgui.dll.

EDIT again: Well, doing require "qtgui" causes a crash, so replacing lcairo isn't going to happen. But QString seems to work fine.
« Last Edit: 2011-01-14 17:33:20 by SirReal »

lethys

  • Moderator
  • Jr. Member
  • *****
  • Posts: 78
Re: HKTools 0.20 (IP, TS3, MIRANDA, foobar2000)
« Reply #18 on: 2011-01-14 19:52:02 »
I tried looking for this before but I could only find the sf.net page with source code and getting a build environment working in windows is too much hassle for me.
So I got it working and it loads qtcore just fine. Would you care to give me a short example on how to define a QString ?

EDIT: My problem seems to be that for some reason within hk.lua which is supposed to be sort of a library module I can't load modules with "require('qtcore')" for example, it only works if I load them locally e.g. "local require('qtcore')", after which I can't access QString as a global value
« Last Edit: 2011-01-14 20:01:42 by lethys »

SirReal

  • Administrator
  • Hero Member
  • *****
  • Posts: 735
    • linkdata.se
Re: HKTools 0.20 (IP, TS3, MIRANDA, foobar2000)
« Reply #19 on: 2011-01-14 20:05:10 »
QStrings internally store data like ustring does, 16-bit words.
Docs are @ http://doc.qt.nokia.com/latest/qstring.html

Static methods are accessed using QString.method, instance methods using lua's sugar instance:method()

-- create a QString from some UTF-8 data, and re-encode to local 8 bit (yields a Lua string)
qs = QString.fromUtf8(lcdhost.state.dir_layout) -- http://doc.qt.nokia.com/latest/qstring.html#fromUtf8
print( qs:toLocal8Bit() ) -- http://doc.qt.nokia.com/latest/qstring.html#toLocal8Bit

-- create a new empty QString from a Lua string
qs = QString.new("Hello Dolly!")


I haven't actually tested those examples, but they *should* work :P

lethys

  • Moderator
  • Jr. Member
  • *****
  • Posts: 78
Re: HKTools 0.20 (IP, TS3, MIRANDA, foobar2000)
« Reply #20 on: 2011-01-14 20:09:37 »
lol suddenly it does, I noticed a few times that reloading the lua plugin does not take all changes i made into account in some occasions. so there you got me reporting something that wasn't a problem again :D

EDIT: Ah the problem i had was that i used "module('hk')" to declare my file as a module for other lua scripts and after this is done stuff like that begins to break for some reason, e.g. LH_Lua: "[string "hk.lua"]:37: attempt to index global 'QString' (a nil value)"
« Last Edit: 2011-01-14 20:13:22 by lethys »

SirReal

  • Administrator
  • Hero Member
  • *****
  • Posts: 735
    • linkdata.se
Re: HKTools 0.20 (IP, TS3, MIRANDA, foobar2000)
« Reply #21 on: 2011-01-14 20:14:00 »
Ok, now I'm confused. Have you found a bug or have a problem I can help with?

lethys

  • Moderator
  • Jr. Member
  • *****
  • Posts: 78
Re: HKTools 0.20 (IP, TS3, MIRANDA, foobar2000)
« Reply #22 on: 2011-01-14 20:43:41 »
I don't know if it's a bug or if it's intended that way
Code: [Select]
require'qtcore'
module('mymodulesname')
test = QString.new("test")
will not work (QString is nil), but
Code: [Select]
require'qtcore'
test = QString.new("test")
module('mymodulesname')
will work

SirReal

  • Administrator
  • Hero Member
  • *****
  • Posts: 735
    • linkdata.se
Re: HKTools 0.20 (IP, TS3, MIRANDA, foobar2000)
« Reply #23 on: 2011-01-14 20:50:46 »
Well, I can't answer that. And by the same token, it's not something I can help with. Possibly the author of lqt might help.
https://github.com/mkottman

lethys

  • Moderator
  • Jr. Member
  • *****
  • Posts: 78
Re: HKTools 0.20 (IP, TS3, MIRANDA, foobar2000)
« Reply #24 on: 2011-01-14 20:56:03 »
Maybe you can help me with this
Code: [Select]
test = QProcess.new()
command = QString.new("ping")
param = QStringList.new()
param:append(QString.new("google.com"))

test:start(command, param, {})
print(test:readAll())

This will lead to:
14.01.2011 21:53:24    WRN    QIODevice::read: WriteOnly device
14.01.2011 21:53:24    DBG    LH_Lua: ""

QProcess:start expects a table as last argument, I'm not clear on what the format of that should be so I left it empty, from the documentation I could gather that it sets the mode but I didn't learn much more.

SirReal

  • Administrator
  • Hero Member
  • *****
  • Posts: 735
    • linkdata.se
Re: HKTools 0.20 (IP, TS3, MIRANDA, foobar2000)
« Reply #25 on: 2011-01-14 21:27:01 »
Wow, you just dive right in, don't you?  :D
I haven't had that much luck getting QProcess redirection to work properly.
I tried using it for the WebKitServer IPC, but it just wouldn't work, so I ended up using a named pipe.

To try and help: Since the actual API call (http://doc.qt.nokia.com/latest/qprocess.html#start) requires an enum from QIODevice (http://doc.qt.nokia.com/latest/qiodevice.html#OpenModeFlag-enum), I would guess that the third parameter should either be a named field in QIODevice or a string.

Best guess:

Code: [Select]
test:start(command, param, QIODevice.ReadWrite)

lethys

  • Moderator
  • Jr. Member
  • *****
  • Posts: 78
Re: HKTools 0.20 (IP, TS3, MIRANDA, foobar2000)
« Reply #26 on: 2011-01-14 21:49:44 »
well somebody had that question a while ago and there is some useful stuff you can do with it even though it's ungraceful on a windows system :D

lethys

  • Moderator
  • Jr. Member
  • *****
  • Posts: 78
Re: HKTools 0.20 (IP, TS3, MIRANDA, foobar2000)
« Reply #27 on: 2011-01-14 22:12:28 »
congratulations you were right:
Code: [Select]
test = QProcess.new()
command = QString.new("C:\\WINXP\\system32\\ping.EXE")
param = QStringList.new()
param:append(QString.new("google.com"))
test:start(command, param, {'ReadOnly'})
print(test:waitForFinished())
print(test:readAll())
yields:
Code: [Select]
14.01.2011 23:10:43 DBG LH_Lua: "true"
14.01.2011 23:10:43 DBG LH_Lua: "

Ping google.com [209.85.149.147] mit 32 Bytes Daten:



Antwort von 209.85.149.147: Bytes=32 Zeit=30ms TTL=57

Antwort von 209.85.149.147: Bytes=32 Zeit=32ms TTL=57

Antwort von 209.85.149.147: Bytes=32 Zeit=29ms TTL=57

Antwort von 209.85.149.147: Bytes=32 Zeit=30ms TTL=57



Ping-Statistik fr 209.85.149.147:

    Pakete: Gesendet = 4, Empfangen = 4, Verloren = 0 (0% Verlust),

Ca. Zeitangaben in Millisek.:

    Minimum = 29ms, Maximum = 32ms, Mittelwert = 30ms

"

SirReal

  • Administrator
  • Hero Member
  • *****
  • Posts: 735
    • linkdata.se
Re: HKTools 0.20 (IP, TS3, MIRANDA, foobar2000)
« Reply #28 on: 2011-01-14 22:15:35 »
Well, woohoo for me. =)

lethys

  • Moderator
  • Jr. Member
  • *****
  • Posts: 78
Re: HKTools 0.20 (IP, TS3, MIRANDA, foobar2000)
« Reply #29 on: 2011-01-14 22:33:16 »
i would appreciate some more help with cairo, so far i think i realized that anti alias is set using font options, but I am pretty much baffled by the details  :-\

 

anything