| Y.B. 的个人资料wavewaving's 爬痕照片日志列表 | 帮助 |
|
2009/9/7 用鼠标手势实现firefox的Paste and Search在小众软件上看到 Paste and Go 的FireGestures 脚本(http://www.appinn.com/gestures-firefox-paste-and-go/ ),看着ms挺简单,不过却是很有趣。文章末尾,作者说要是有个 搜索剪贴板内容的功能 就好了。想想ms这功能也蛮有意思。于是搜索了下,执行搜索框的firefox函数。虽然不懂,不过依样画葫芦,居然成功实现了功能。呵呵,脚本非常简单,如下图:
文本如下:
var str = readFromClipboard();
if (!str) return; BrowserSearch.loadSearch(str, true); 名称和动作全是山寨的。:).
在firefox窗口里,按鼠标右键,向右,向上,再向左,即逆时针半圈 (R U L),就能打开一个页面并搜索剪切板里的内容了。
下边是个高级的多功能版本,参考http://www.xuldev.org/firegestures//feedback.php上的一些例子:
其功能是,如果当前点是链接,那么在新窗口页打开链接,如果是选择文本,(如果未选择,即文本为空,则取剪贴板内内容),若该文本是链接,则在新窗口页打开链接,如果是普通文本,则当作搜索内容进行搜索。不过这里,判断文本链接的正则非常初级,需要改进。
//Open link & Go /Selected & Go or Search/Paste & Go or Search
// (1) If you started gesture from a link, do 'Open Link in New Tab'
var srcNode = FireGestures.sourceNode; var linkURL = FireGestures.getLinkURL(srcNode); if (linkURL) { gBrowser.loadOneTab(linkURL, null, null, null, true, false); return; } // (2) Else if you select nothing, do 'Search for clipboard text'
var sel = FireGestures.getSelectedText(); if (sel == "") { sel = readFromClipboard(); if (!sel) return; } // (3) Else if you select text, do 'Search for Selection' if (sel){ if (sel.match(/^www.|^http:|html?$/)) // rough version, need further improvement {var taa = gBrowser.loadOneTab(sel, null, null, null, true, false); gBrowser.moveTabTo(taa, ++gBrowser.mCurrentTab._tPos);} else {BrowserSearch.loadSearch(sel, true); return;} } 2009/9/5 Tips for CAMFR installation with Python2.6to memorize the past day.
System info:
Ubuntu 9.10 alpha4
$ cat /proc/version
Linux version 2.6.31-5-generic (buildd@crested) (gcc version 4.4.1 (Ubuntu 4.4.1-1ubuntu1) ) #24-Ubuntu SMP Sat Aug 1 12:47:58 UTC 2009 $ python --version
Python 2.6.2+ CAMFR release version: camfr20070717
1, Insert one decaration line to CAMFR_20070717/camfr/defs.h due to some problem related to new GCC compiler.
#include <cstdlib>
or it will lead to some errors like:
...
camfr/primitives/section/../../util/vectorutil.h:66: error: call of overloaded abs(long int) is ambiguous
/usr/include/c++/4.4/cmath:102: note: candidates are: long double std::abs(long double) /usr/include/c++/4.4/cmath:98: note: float std::abs(float) ...
The declaration for std::abd(long int) is in 'cstdlib'
2, Using apt-get to install the softwares indicated in the guidance from INSTALL.
3, using the following file "machine_cfg.py" for setup. Chang it to fit your system.
#-----------------------------------------------
# This Python script contains all the machine dependent settings
# needed during the build process. # Compilers to be used.
cc = "gcc"
cxx = "g++" f77 = "gfortran -fPIC" # using gfortran compiler link = cxx
link_flags = "" # Compiler flags.
# # Note: for the Fortran name definition you can define one of the following # preprocessor macros: # # FORTRAN_SYMBOLS_WITHOUT_TRAILING_UNDERSCORES # FORTRAN_SYMBOLS_WITH_SINGLE_TRAILING_UNDERSCORE # FORTRAN_SYMBOLS_WITH_DOUBLE_TRAILING_UNDERSCORES # For 32bit cpu, may use FORTRAN_SYMBOLS_WITH_SINGLE_TRAILING_UNDERSCORE
base_flags = "-DFORTRAN_SYMBOLS_WITH_DOUBLE_TRAILING_UNDERSCORES -DNDEBUG "
flags_noopt = base_flags
# -march=core2 is for current cpu, set others if different
flags = base_flags + "-O3 -march=core2 -g -funroll-loops "
fflags = flags + "-fPIC "
# Include directories. # special setting for python2.6
include_dirs = ["/usr/include/python2.6", "/usr/lib/python2.6/dist-packages"]
# Library directories. # I use intel mkl mathmatical library. Leave it blank if not.
library_dirs = ["/opt/intel/mkl/10.2.1.017/lib/em64t"]
# library_dirs = []
# Library names. # use the library related to your system
libs = ["boost_python-mt", "blitz", "mkl_lapack", "mkl_core", "gfortran"]
# Command to strip library of excess symbols:
dllsuffix = ".so"
strip_command = "strip --strip-unneeded camfr/_camfr" + dllsuffix strip_command = "" # Extra files to copy into installation directory.
extra_files = [("doc", ["docs/camfr.pdf"])]
#------------------------------------------
For python 2.6, it seems that "site-packages" is replaced by "dist-packages". |
|
|