As an happy user of the SciTE editor I was missing this feature in Komodo Edit which by the way is an excellent product.
Comment/uncomment means that a "special" comment string is used, i.e. #~ for Python. If this string is present at beginning of line the macro removes it (uncomment); if not it is inserted (comment). Python and PHP only for now, and poor code for sure. Any help is welcome.
import logging
logger = logging.getLogger('macro')
h = logging.FileHandler("/tmp/somefile", "w")
logger.addHandler(h)
ke = komodo.editor
kd = komodo.document
kv = komodo.view
commentMap = {
u'python': '#~ ',
u'php': '//~ ',
u'javascript': '//~ ',
u'c++': '//~ ',
}
commentTxt = commentMap[kd.language.lower()]
def EVAL(stmt):
res = eval(stmt)
logger.error("%s --> %s" % (stmt, res))
def getLineNo(position=None):
pos = position or ke.currentPos
return ke.lineFromPosition(pos)
def getLine(lineNo=None):
line = lineNo or getLineNo()
eol = ke.getLineEndPosition(line)
return ke.getTextRange(ke.currentPos, eol)
def vCHome(lineNo=None):
if (lineNo is not None):
ke.gotoLine(lineNo)
ke.vCHome()
if (getLine().strip() == ''):
return
if (ke.getTextRange(ke.currentPos, ke.currentPos+1).isspace()):
ke.vCHome()
def doLine(lineNo=None):
vCHome(lineNo)
pos = ke.currentPos
s = ke.getTextRange(pos, pos+len(commentTxt))
if (s == commentTxt):
ke.setSel(pos, pos+len(commentTxt))
ke.replaceSel('')
else:
ke.insertText(pos, commentTxt)
komodo.view.setFocus()
try:
pStart = ke.anchor
pEnd = ke.currentPos
lStart = ke.lineFromPosition(pStart)
lEnd = ke.lineFromPosition(pEnd)
if (lEnd < lStart):
tmp = lStart
lStart = lEnd
lEnd = tmp
for line in range(lStart, lEnd+1):
doLine(line)
except:
logger.error("Error", exc_info=True)
return
On a Linux server I have a LSI/Symbios MegaRAID SATA 150-4 device. Here's the output of lspci -v
01:08.0 RAID bus controller: LSI Logic / Symbios Logic MegaRAID (rev 01)
Subsystem: LSI Logic / Symbios Logic MegaRAID SATA 150-4 RAID Controller
Flags: bus master, 66MHz, slow devsel, latency 128, IRQ 66
Memory at fdff0000 (32-bit, prefetchable) [size=64K]
Expansion ROM at fc000000 [disabled] [size=64K]
Capabilities: [80] Power Management version 2
The device works OK, but the documentation, while almost clear and complete is distributed as an horribly formatted ms word file. So I made little formatting modifications and have the same documentation available as HTML and PDF formats.
Index: build/lib/configure.bat
===================================================================
--- build/lib/configure.bat (revision 3112)
+++ build/lib/configure.bat (working copy)
@@ -258,6 +258,7 @@
:oc_evc8
echo Setting compiler: Microsoft Visual C++ .NET 2005 for Windows CE
echo COMPILER_NAME=evc8 >> ..\Makefiles\config.mak
+echo TARGET_PROC=arm >> ..\Makefiles\config.mak
set SELECTED_COMPILER_VERSION=80
if "%OSVERSION%"=="" (
echo OSVERSION not set, assuming target is CE 5.0
Index: build/Makefiles/nmake/evc8.mak
===================================================================
--- build/Makefiles/nmake/evc8.mak (revision 3112)
+++ build/Makefiles/nmake/evc8.mak (working copy)
@@ -54,14 +54,14 @@
# Note: /GX for MSC<14 has been replaced with /EHsc
-CFLAGS_COMMON = /nologo /TC /W4 /GF /GR /EHsc
+CFLAGS_COMMON = /nologo /TC /W4 /GF /GR /EHsc /wd4201
CFLAGS_REL = $(CFLAGS_COMMON) $(OPT_REL)
CFLAGS_STATIC_REL = $(CFLAGS_COMMON) $(OPT_STATIC_REL)
CFLAGS_DBG = $(CFLAGS_COMMON) $(OPT_DBG)
CFLAGS_STATIC_DBG = $(CFLAGS_COMMON) $(OPT_STATIC_DBG)
CFLAGS_STLDBG = $(CFLAGS_COMMON) $(OPT_STLDBG)
CFLAGS_STATIC_STLDBG = $(CFLAGS_COMMON) $(OPT_STATIC_STLDBG)
-CXXFLAGS_COMMON = /nologo /TP /W4 /GF /GR /EHsc
+CXXFLAGS_COMMON = /nologo /TP /W4 /GF /GR /EHsc /wd4201
CXXFLAGS_REL = $(CXXFLAGS_COMMON) $(OPT_REL)
CXXFLAGS_STATIC_REL = $(CXXFLAGS_COMMON) $(OPT_STATIC_REL)
CXXFLAGS_DBG = $(CXXFLAGS_COMMON) $(OPT_DBG)
Index: src/fstream_win32io.cpp
===================================================================
--- src/fstream_win32io.cpp (revision 3112)
+++ src/fstream_win32io.cpp (working copy)
@@ -79,12 +79,25 @@
#endif
_STLP_MOVE_TO_PRIV_NAMESPACE
-
-// Helper functions for _Filebuf_base.
-
+
+#if defined(_STLP_WCE)
+
+// GetFileType does not exist on CE. Try to reimplement it
+bool __is_regular_file(_STLP_fd fd) {
+ BY_HANDLE_FILE_INFORMATION info;
+ if (0 == GetFileInformationByHandle(fd, &info))
+ return false;
+ return !(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
+}
+
+#else
+
+// Helper functions for _Filebuf_base.
bool __is_regular_file(_STLP_fd fd) {
return (GetFileType(fd) & ~FILE_TYPE_REMOTE) == FILE_TYPE_DISK;
-}
+}
+
+#endif //_STLP_WCE
// Number of characters in the file.
streamoff __file_size(_STLP_fd fd) {
Index: stlport/ctype.h
===================================================================
--- stlport/ctype.h (revision 3112)
+++ stlport/ctype.h (working copy)
@@ -62,6 +62,19 @@
# undef toupper
# undef tolower
+# undef iswalpha
+# undef iswupper
+# undef iswlower
+# undef iswdigit
+# undef iswxdigit
+# undef iswspace
+# undef iswpunct
+# undef iswalnum
+# undef iswprint
+# undef iswgraph
+# undef iswcntrl
+# undef iswascii
+
# if defined (UNDER_CE)
# if (_WIN32_WCE < 300) /* Only wide chars for older versions */
@@ -83,18 +96,18 @@
# undef _isctype
-__inline int (iswalpha)(int c) { return iswctype(c, _ALPHA); }
-__inline int (iswupper)(int c) { return iswctype(c, _UPPER); }
-__inline int (iswlower)(int c) { return iswctype(c, _LOWER); }
-__inline int (iswdigit)(int c) { return iswctype(c, _DIGIT); }
-__inline int (iswxdigit)(int c) { return iswctype(c, _HEX); }
-__inline int (iswspace)(int c) { return iswctype(c, _SPACE); }
-__inline int (iswpunct)(int c) { return iswctype(c, _PUNCT); }
-__inline int (iswalnum)(int c) { return iswctype(c, _ALPHA|_DIGIT); }
-__inline int (iswprint)(int c) { return iswctype(c, _BLANK|_PUNCT|_ALPHA|_DIGIT); }
-__inline int (iswgraph)(int c) { return iswctype(c, _PUNCT|_ALPHA|_DIGIT); }
-__inline int (iswcntrl)(int c) { return iswctype(c, _CONTROL); }
-__inline int (iswascii)(int c) { return ((unsigned)(c) < 0x80); }
+__inline int (iswalpha)(wint_t c) { return iswctype(c, _ALPHA); }
+__inline int (iswupper)(wint_t c) { return iswctype(c, _UPPER); }
+__inline int (iswlower)(wint_t c) { return iswctype(c, _LOWER); }
+__inline int (iswdigit)(wint_t c) { return iswctype(c, _DIGIT); }
+__inline int (iswxdigit)(wint_t c) { return iswctype(c, _HEX); }
+__inline int (iswspace)(wint_t c) { return iswctype(c, _SPACE); }
+__inline int (iswpunct)(wint_t c) { return iswctype(c, _PUNCT); }
+__inline int (iswalnum)(wint_t c) { return iswctype(c, _ALPHA|_DIGIT); }
+__inline int (iswprint)(wint_t c) { return iswctype(c, _BLANK|_PUNCT|_ALPHA|_DIGIT); }
+__inline int (iswgraph)(wint_t c) { return iswctype(c, _PUNCT|_ALPHA|_DIGIT); }
+__inline int (iswcntrl)(wint_t c) { return iswctype(c, _CONTROL); }
+__inline int (iswascii)(wint_t c) { return ((unsigned)(c) < 0x80); }
# endif /* UNDER_CE */
Index: stlport/stl/_cstdlib.h
===================================================================
--- stlport/stl/_cstdlib.h (revision 3112)
+++ stlport/stl/_cstdlib.h (working copy)
@@ -66,6 +66,49 @@
using _STLP_VENDOR_CSTD::mbtowc;
using _STLP_VENDOR_CSTD::system;
using _STLP_VENDOR_CSTD::bsearch;
+
+# else
+
+_STLP_END_NAMESPACE
+
+/* needed for IsDBCSLeadByte and WideCharToMultiByte */
+#include <windows.h>
+#include <winnls.h>
+
+//Wine-based reimplementation of mbtowc and mblen
+inline int mbtowc(wchar_t *wchar,const char *mbchar,size_t count)
+{
+ //temp var needed because MultiByteToWideChar wants non NULL destination
+ wchar_t tmpdst = '\0';
+
+ if(count <= 0 || !mbchar)
+ return 0;
+ //first 0 == CP_ACP, ANSI Code Page
+ if(!::MultiByteToWideChar(0, 0, mbchar, count, &tmpdst, 1))
+ return -1;
+ if(wchar)
+ *wchar = tmpdst;
+ //return the number of bytes from src that have been used
+ if(!*mbchar)
+ return 0;
+ if(count >= 2 && isleadbyte(*mbchar) && mbchar[1])
+ return 2;
+ return 1;
+}
+
+inline int mblen(const char *mbstr,size_t count)
+{
+ if (mbstr && *mbstr && count)
+ {
+ if(MB_CUR_MAX == 1)
+ return 1; // ASCII CP
+ return !isleadbyte(*mbstr) ? 1 : (count>1 ? 2 : -1);
+ }
+ return 0;
+}
+
+_STLP_BEGIN_NAMESPACE
+
# endif
using _STLP_VENDOR_CSTD::atexit;
using _STLP_VENDOR_CSTD::exit;
@@ -80,12 +123,28 @@
using _STLP_VENDOR_CSTD::strtod;
using _STLP_VENDOR_CSTD::strtol;
using _STLP_VENDOR_CSTD::strtoul;
+using _STLP_VENDOR_CSTD::mblen;
+using _STLP_VENDOR_CSTD::mbtowc;
# if !(defined (_STLP_NO_NATIVE_WIDE_STREAMS) || defined (_STLP_NO_MBSTATE_T))
using _STLP_VENDOR_CSTD::wcstombs;
-# ifndef _STLP_WCE
+# ifdef _STLP_WCE
+
+_STLP_END_NAMESPACE
+
+//Wine-based reimplementation
+inline int wctomb(char *mbchar, wchar_t wchar)
+{
+ //first 0 is CP_ACP, ANSI codepage
+ return ::WideCharToMultiByte(0, 0, &wchar, 1, mbchar, 6, NULL, NULL);
+}
+
+_STLP_BEGIN_NAMESPACE
+
+# endif //_STLP_WCE
+
using _STLP_VENDOR_CSTD::wctomb;
-# endif
+
# endif
using _STLP_VENDOR_CSTD::qsort;
using _STLP_VENDOR_CSTD::labs;
Index: stlport/stl/config/host.h
===================================================================
--- stlport/stl/config/host.h (revision 3112)
+++ stlport/stl/config/host.h (working copy)
@@ -72,10 +72,9 @@
* _STLP_NATIVE_INCLUDE_PATH.
* Hint: never install STLport in the directory that ends with "include"
*/
-/*
+
#undef _STLP_NATIVE_INCLUDE_PATH
-#define _STLP_NATIVE_INCLUDE_PATH ../include
-*/
+
/* same for C library headers like <cstring> */
/*
#undef _STLP_NATIVE_CPP_C_INCLUDE_PATH
After a few minutes of mild swearing I found an INVALUABLE document by http://www.robinz.info/ which resolves EVERYTHING.
Here's the original article: http://blog.robinz.info/archives/2006/03/17/install-vmware-server-on-debian-amd64em64t/
So, what's the point of this post?
I moved some websites from an old Win2k Server to a new one with MDAC 2.8. Suddenly, one of the sites didn't work anymore, with an error message like:
Microsoft VBScript run-time error (0x800A01F4)
Undefined variable: 'adUseClient'
or, in Italian as I got it:
Errore di run-time di Microsoft VBScript (0x800A01F4)
Variabile non definita: 'adUseClient'
Of course these sites are VB/ASP crap and I don't know VB/ASP. Nor will, I hope. So, after googling around for a COUPLE OF F*CKIN' HOURS I found that somewhat the author has forgotten a simple line:
<!-- #include file = "adovbs.inc"-->
Well, I don't know what this file is, nor where you can find it. I know it solved the problem. Maybe the next unlucky sysadmin will spend only a few minutes to get over this shit...
| STLPort-5.1.2-VS8-ARMV4I.tgz (~11MB) |
stlport.5.1.dll stlport.5.1.exp stlport.5.1.lib stlport.5.1.pdb stlport_static.5.1.lib stlport_static.5.1.pdb stlportd.5.1.dll stlportd.5.1.exp stlportd.5.1.lib stlportd.5.1.pdb stlportd_static.5.1.lib stlportd_static.5.1.pdb stlportstld.5.1.dll stlportstld.5.1.exp stlportstld.5.1.lib stlportstld.5.1.pdb stlportstld_static.5.1.lib stlportstld_static.5.1.pdb |
| STLPort-5.1.2-VS8-ARMV4I-noPDB.tgz (~8.5MB) |
stlport.5.1.dll stlport.5.1.exp stlport.5.1.lib stlport_static.5.1.lib stlportd.5.1.dll stlportd.5.1.exp stlportd.5.1.lib stlportd_static.5.1.lib stlportstld.5.1.dll stlportstld.5.1.exp stlportstld.5.1.lib stlportstld_static.5.1.lib |
| STLPort-5.1.2-VS8-ARMV4I-Release.tgz (~3.2MB) |
stlport.5.1.dll stlport.5.1.lib stlport.5.1.pdb stlport_static.5.1.lib stlport_static.5.1.pdb |
| STLPort-5.1.2-VS8-ARMV4I-Debug.tgz (~4.5MB) |
stlportstld.5.1.dll stlportstld.5.1.exp stlportstld.5.1.lib stlportstld.5.1.pdb stlportstld_static.5.1.lib stlportstld_static.5.1.pdb |
The DMProcessConfigXML function can be used on Windows CE 5 device to easily access configuration management subsystems.
As usual the documentation is not optimal and lacks real life examples. Here I'll detail how to setup a Wi-Fi connection programmatically in C++. This newly created connection will appear among all other connections created from the control panel. This method may be used (with other configuration service providers) to backup a PocketPC configuration.
A few things to keep in mind anytime:
DMProcessConfigXML syscall and its prototype are defined in cfgmgrapi.h header.connmgr.h header.
Now the real meat: this XML will add or overwrite a Wi-Fi access point connection with SSID COWO, no encryption, open authentication. This connection is regarded as an internet connection.
LPCWSTR in = \
L"<wap-provisioningdoc>"
L" <characteristic type=\"Wi-Fi\"> "
L" <characteristic type=\"access-point\"> "
L" <characteristic type=\"COWO\"> "
L" <parm name=\"DestId\" value=\"{436EF144-B4FB-4863-A041-8F905A62C572}\"/>"
L" <parm name=\"AdHoc\" value=\"0\"/>"
L" <parm name=\"Authentication\" value=\"0\"/>"
L" <parm name=\"Encryption\" value=\"1\"/>"
L" <parm name=\"KeyProvided\" value=\"0\"/>"
L" <parm name=\"NetworkKey\" value=\"\"/>"
L" <parm name=\"KeyIndex\" value=\"1\"/>"
L" <parm name=\"Use8021x\" value=\"0\"/>"
L" <parm name=\"EAPType\" value=\"25\"/>"
L" </characteristic>"
L" </characteristic>"
L" </characteristic>"
L"</wap-provisioningdoc>";
LPWSTR out = NULL;
HRESULT res = ::DMProcessConfigXML(in, CFGFLAG_PROCESS, &out);
delete[] out;
out will contain a copy of the configuration just inserted, and return value should be S_OK.
Query works in the same way. There are some M$ examples about recursive query of all WiFi connections. Here's an example on how to query a specific connection.
L"<wap-provisioningdoc>"
L" <characteristic type=\"Wi-Fi\"> "
L" <characteristic type=\"access-point\"> "
L" <characteristic-query type=\"COWO\" /> "
L" </characteristic>"
L" </characteristic>"
L"</wap-provisioningdoc>";
LPWSTR out = NULL;
HRESULT res = ::DMProcessConfigXML(in, CFGFLAG_PROCESS, &out);
delete[] out;
You may need to use GetSystemMetrics to query cursor width and height, as described in the documentation. Unfortunately, there are definitions missing in winuser.h, so you have to add them by hand:
#ifndef SM_CXCURSOR
#define SM_CXCURSOR 13
#endif
#ifndef SM_CYCURSOR
#define SM_CYCURSOR 14
#endif
Another problem I found is that the auto_ptr class misses the reset method implementation. A brain-dead solution is to derive a new class from the auto_ptr and add this reset implementation (taken from another MS STL):
void reset(_Ty* P = 0) {
// destroy designated object and store new pointer
if (_Ptr != P)
delete (_Ty *)_Ptr;
_Ptr = P;
_Owns = (P != 0);
}
This is a rough and working implementation that relies on WM_CTLCOLOR message handling. Comments are in Italian but code is so stupid that I think even a spider could understand it.
License is LGPL
Header file
/** \file
\date $Date: 2007/01/10 17:09:43 $
\version $Revision: 1.1 $
*/
#ifndef __IPAQ_CLIENT_COLOR_BUTTON_H
#define __IPAQ_CLIENT_COLOR_BUTTON_H
#include <afxwin.h>
/** Subclass del pulsante standard che
permette una colorazione personalizzabile */
class CColorButton : public CButton
{
public:
CColorButton();
/** Specifica il colore in fase di creazione */
CColorButton(COLORREF color);
virtual ~CColorButton();
/** Ignoro il secondo parametro. Spero che arrivi
sempre il CTLCOLOR_BTN */
afx_msg HBRUSH CtlColor (CDC* pDC, UINT nCtlColor);
protected:
COLORREF m_Color;
CBrush m_BackBrush;
DECLARE_MESSAGE_MAP()
DECLARE_DYNAMIC(CColorButton)
};
#endif //__IPAQ_CLIENT_COLOR_BUTTON_H
Source file
/** \file
\date $Date: 2007/01/10 17:09:43 $
\version $Revision: 1.1 $
*/
#include "stdafx.h"
#include "ColorButton.h"
IMPLEMENT_DYNAMIC(CColorButton, CButton)
CColorButton::CColorButton()
{
m_Color = ::GetSysColor(COLOR_WINDOW);
m_BackBrush.CreateSolidBrush(m_Color);
}
CColorButton::CColorButton(COLORREF color) :
m_Color(color),
m_BackBrush(color)
{}
CColorButton::~CColorButton()
{}
BEGIN_MESSAGE_MAP(CColorButton, CButton)
ON_WM_CTLCOLOR_REFLECT()
END_MESSAGE_MAP()
HBRUSH CColorButton::CtlColor(CDC* pDC, UINT nCtlColor)
{
return (HBRUSH)m_BackBrush;
}
|
|
January '09 | |||||
| Mo | Tu | We | Th | Fr | Sa | Su |
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | 31 | |
2006-2008 Giuseppe 'Cowo' Corbelli | Cowo's homepage | Cowo's photo page | Contact me | Back to top
Design by Andreas Viklund | Serendipity Template by Carl