assorted-commits Mailing List for Assorted projects (Page 21)
Brought to you by:
yangzhang
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(9) |
Dec
(12) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(86) |
Feb
(265) |
Mar
(96) |
Apr
(47) |
May
(136) |
Jun
(28) |
Jul
(57) |
Aug
(42) |
Sep
(20) |
Oct
(67) |
Nov
(37) |
Dec
(34) |
2009 |
Jan
(39) |
Feb
(85) |
Mar
(96) |
Apr
(24) |
May
(82) |
Jun
(13) |
Jul
(10) |
Aug
(8) |
Sep
(2) |
Oct
(20) |
Nov
(31) |
Dec
(17) |
2010 |
Jan
(16) |
Feb
(11) |
Mar
(17) |
Apr
(53) |
May
(31) |
Jun
(13) |
Jul
(3) |
Aug
(6) |
Sep
(11) |
Oct
(4) |
Nov
(17) |
Dec
(17) |
2011 |
Jan
(3) |
Feb
(19) |
Mar
(5) |
Apr
(17) |
May
(3) |
Jun
(4) |
Jul
(14) |
Aug
(3) |
Sep
(2) |
Oct
(1) |
Nov
(3) |
Dec
(2) |
2012 |
Jan
(3) |
Feb
(7) |
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
(4) |
Aug
(5) |
Sep
(2) |
Oct
(3) |
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
(9) |
Apr
(5) |
May
|
Jun
(2) |
Jul
(1) |
Aug
(10) |
Sep
(1) |
Oct
(2) |
Nov
|
Dec
|
2014 |
Jan
(1) |
Feb
(3) |
Mar
(3) |
Apr
(1) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2016 |
Jan
(1) |
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(5) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <yan...@us...> - 2009-05-07 09:54:49
|
Revision: 1402 http://assorted.svn.sourceforge.net/assorted/?rev=1402&view=rev Author: yangzhang Date: 2009-05-07 09:54:41 +0000 (Thu, 07 May 2009) Log Message: ----------- added clobber-if-diff to readme Modified Paths: -------------- shell-tools/trunk/README Modified: shell-tools/trunk/README =================================================================== --- shell-tools/trunk/README 2009-05-07 09:52:49 UTC (rev 1401) +++ shell-tools/trunk/README 2009-05-07 09:54:41 UTC (rev 1402) @@ -19,7 +19,7 @@ - [GHC] 6.8 - [Perl] 5 -- [Python] 2.4+ +- [Python] 2.5+ - [keychain] for `bashrc.bash` - [stow] for `refresh-*` @@ -52,6 +52,9 @@ from a directory tree. implementation, [HSH] +`clobber- Only replace an existing file if the contents Python +if-diff` actually changed. Useful in Makefiles. + `daemon-ctl` `start-stop-daemon` but with extra features. bash, procps `filter-urls` Given a list of URLs, filter out live URLs or Python This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 09:52:53
|
Revision: 1401 http://assorted.svn.sourceforge.net/assorted/?rev=1401&view=rev Author: yangzhang Date: 2009-05-07 09:52:49 +0000 (Thu, 07 May 2009) Log Message: ----------- fixed bug with remove and nonexistent destination Modified Paths: -------------- shell-tools/trunk/src/clobber-if-diff.py Modified: shell-tools/trunk/src/clobber-if-diff.py =================================================================== --- shell-tools/trunk/src/clobber-if-diff.py 2009-05-07 07:49:02 UTC (rev 1400) +++ shell-tools/trunk/src/clobber-if-diff.py 2009-05-07 09:52:49 UTC (rev 1401) @@ -11,7 +11,7 @@ if os.path.isfile(outpath): if 0 == subprocess.call(['cmp', '-s', inpath, outpath]): return opts.exitcode - if opts.remove: os.remove(outpath) + if opts.remove and os.path.isfile(outpath): os.remove(outpath) if opts.copy: shutil.copy(inpath, outpath) else: shutil.move(inpath, outpath) return 0 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 07:49:03
|
Revision: 1400 http://assorted.svn.sourceforge.net/assorted/?rev=1400&view=rev Author: yangzhang Date: 2009-05-07 07:49:02 +0000 (Thu, 07 May 2009) Log Message: ----------- added todo Modified Paths: -------------- simple-build/trunk/README Modified: simple-build/trunk/README =================================================================== --- simple-build/trunk/README 2009-05-07 07:48:18 UTC (rev 1399) +++ simple-build/trunk/README 2009-05-07 07:49:02 UTC (rev 1400) @@ -121,6 +121,7 @@ - selective target specification: enable configuration of rules (esp. `all`) to build only certain targets that the user is interested in (currently all configurations of all programs are built) +- conveniently express dynamic dependenciess (vs. GNU Make `-include` hacks) Related Work ------------ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 07:48:19
|
Revision: 1399 http://assorted.svn.sourceforge.net/assorted/?rev=1399&view=rev Author: yangzhang Date: 2009-05-07 07:48:18 +0000 (Thu, 07 May 2009) Log Message: ----------- tweak Modified Paths: -------------- container-bench/trunk/tools/runner.bash Modified: container-bench/trunk/tools/runner.bash =================================================================== --- container-bench/trunk/tools/runner.bash 2009-05-07 07:47:54 UTC (rev 1398) +++ container-bench/trunk/tools/runner.bash 2009-05-07 07:48:18 UTC (rev 1399) @@ -11,4 +11,4 @@ LD_PRELOAD="$src/../../../sandbox/trunk/src/nix/preload/interposer.so" \ "$src/bench" $i done -done > log +done | tee log This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 07:47:57
|
Revision: 1398 http://assorted.svn.sourceforge.net/assorted/?rev=1398&view=rev Author: yangzhang Date: 2009-05-07 07:47:54 +0000 (Thu, 07 May 2009) Log Message: ----------- updated links Modified Paths: -------------- personal-site/trunk/src/links.txt Modified: personal-site/trunk/src/links.txt =================================================================== --- personal-site/trunk/src/links.txt 2009-05-07 07:46:35 UTC (rev 1397) +++ personal-site/trunk/src/links.txt 2009-05-07 07:47:54 UTC (rev 1398) @@ -16,8 +16,9 @@ - [All my feed subscriptions] ([RSS]): All my Google Reader subscriptions, merged via Yahoo Pipes. Like my shared items, this is still mostly technical content. -- [Facebook](http://www.facebook.com/profile.php?id=708869) -- [LinkedIn](http://www.linkedin.com/in/yzhang) +- [Facebook profile](http://www.facebook.com/profile.php?id=708869) +- [LinkedIn profile](http://www.linkedin.com/in/yzhang) +- [Google profile](http://www.google.com/profiles/yaaang) [My blog]: http://y_z.scripts.mit.edu/wp/ [Bookmarks]: http://del.icio.us/yaaang/ @@ -30,59 +31,59 @@ ----------------- - [All Things Distributed]: Werner Vogels' blog (Amazon CTO and former CMU - prof). Focus on distributed systems. Low frequency. + prof). Focus on distributed systems and AWS. Low frequency. - [Ars Technica]: Jon "Hannibal" Stokes' great explanatory articles on computer architecture topics. Low frequency. -- [C++ Reference Guide]: Details, details, details. Also covers C++0x. Low - frequency. - [Evan Jones' Scratch Pad]: Labmate's blog on systems topics with occasional low-level articles on programming. Low frequency. - [Geeking with Greg]: A blog by Greg Linden, the guy behind Amazon's recommendation and personalization systems, now at MS Live Labs. Lots of good - discussion on IR research. Low frequency. + discussion on IR and related research. Low frequency. - [Haskell Weekly News]: Briefs about updates in the wonderful world of Haskell. - [High Scalability]: Blog on systems and scalability, particularly in the web - applications/datacenter universe. The author frequently provides useful - summarizing notes. Medium frequency. -- [Kernel Trap]: Digests of notable developments on the [Linux kernel mailing - list]. Low frequency. + applications/datacenter universe. High noise, but sometimes useful notes are + posted. Medium frequency. - [Lambda The Ultimate]: A discussion forum on programming languages, with a - heavy emphasis on "PL design." The rabbit hole is deep, so about half their - stories/forum topics end up interesting (accessible to) me. Medium frequency. + heavy emphasis on "PL design." Medium frequency. - [Linux Weekly News]: Jonathan Corbet writes good explanatory articles in the Weekly Edition. +- [Paper Trail]: Explanatory summaries on distributed systems research, old and + new. Low frequency. +- [Papers in Computer Science]: Superb summaries and discussion on seminal + papers across all of CS. Medium frequency. +- [Saturday Morning Breakfast Cereal]: Sick strip. - [The Monad Reader]: The Haskell magazine. "It is less formal than journal, but somehow more enduring than a wiki-page." An issue every few months. -- [p2p-hackers]: Discussion forum on anything related to networking and - distributed systems, with no shortage of discussion on research in these - fields. Medium frequency. -- [research!rsc]: Labmate Russ Cox's blog. Lots of focus on history of - computing. Low frequency. +- [research!rsc]: Labmate Russ Cox's blog. Focus on history of computing. Low + frequency. [All Things Distributed]: http://www.allthingsdistributed.com/ [Ars Technica]: http://arstechnica.com/index.ars -[C++ Reference Guide]: http://www.informit.com/guides/guide.aspx?g=cplusplus [Evan Jones' Scratch Pad]: http://evanjones.ca/ [Geeking with Greg]: http://glinden.blogspot.com/ [Haskell Weekly News]: http://sequence.complete.org/hwn/ [High Scalability]: http://www.highscalability.com/ [Kernel Trap]: http://kerneltrap.org/ -[Linux kernel mailing list]: http://lkml.org/ [Lambda The Ultimate]: http://www.lambda-the-ultimate.org/ [Linux Weekly News]: http://www.lwn.net/ +[Paper Trail]: http://hnr.dnsalias.net/wordpress/ +[Papers in Computer Science]: http://papersincomputerscience.org/ +[Saturday Morning Breakfast Cereal]: http://www.smbc-comics.com/ [The Monad Reader]: http://www.haskell.org/haskellwiki/The_Monad.Reader -[p2p-hackers]: http://lists.zooko.com/mailman/listinfo/p2p-hackers [research!rsc]: http://research.swtch.com/ -Favorite Conferences --------------------- +Conferences +----------- - Systems - [ASPLOS](http://www.acm.org/pubs/contents/proceedings/series/asplos/) - [OSDI](http://www.usenix.org/event/byname/osdi.html) - [SOSP](http://www.sosp.org/) - [USENIX](http://www.usenix.org/event/byname/usenix.html) +- Databases + - [SIGMOD](http://www.sigmod.org/) + - [VLDB](http://www.vldb.org/) - Networking - [SIGCOMM](http://www.sigcomm.org/) - [NSDI](http://www.usenix.org/event/byname/nsdi.html) @@ -98,10 +99,10 @@ ------------------ - [Campusfood](http://campusfood.com/) +- [Facebook](http://facebook.com/) - [Google Calendar](http://calendar.google.com/) - [Google Reader](http://reader.google.com/) - [Remember the Milk](http://rememberthemilk.com/) -- [Songza](http://songza.com/) Podcasts and Videos ------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 07:46:36
|
Revision: 1397 http://assorted.svn.sourceforge.net/assorted/?rev=1397&view=rev Author: yangzhang Date: 2009-05-07 07:46:35 +0000 (Thu, 07 May 2009) Log Message: ----------- added randspeed to compare performance of rand impls Modified Paths: -------------- rand-dist/trunk/src/Makefile rand-dist/trunk/src/randdist.cc Added Paths: ----------- rand-dist/trunk/src/randspeed.cc Modified: rand-dist/trunk/src/Makefile =================================================================== --- rand-dist/trunk/src/Makefile 2009-05-07 07:44:39 UTC (rev 1396) +++ rand-dist/trunk/src/Makefile 2009-05-07 07:46:35 UTC (rev 1397) @@ -1,2 +1,2 @@ CFLAGS := -Wall -O3 -all: randdist +all: randdist randspeed Modified: rand-dist/trunk/src/randdist.cc =================================================================== --- rand-dist/trunk/src/randdist.cc 2009-05-07 07:44:39 UTC (rev 1396) +++ rand-dist/trunk/src/randdist.cc 2009-05-07 07:46:35 UTC (rev 1397) @@ -16,6 +16,8 @@ const int size = atoi(argv[1]); const int count = atoi(argv[2]); + posix_rand r; + vector<int> xs(size); for (int i = 0; i < count; i++) { xs[i] = r(); Added: rand-dist/trunk/src/randspeed.cc =================================================================== --- rand-dist/trunk/src/randspeed.cc (rev 0) +++ rand-dist/trunk/src/randspeed.cc 2009-05-07 07:46:35 UTC (rev 1397) @@ -0,0 +1,29 @@ +#include <commons/rand.h> +#include <commons/time.h> +#include <iostream> +using namespace commons; +using namespace std; + +int count; + +template<typename T> +void exp(T r, const string &name) +{ + int x = 0; + long long start = current_time_millis(); + for (int i = 0; i < count; ++i) x |= r(); + long long diff = current_time_millis() - start; + cout << name << ": " << diff << " ms or " + << 1000 * count / double(diff) << " r/s; " << hex << x << endl; +} + +int main(int argc, char **argv) { + if (argc < 2) { + cerr << "randspeed COUNT" << endl; + return 1; + } + count = atoi(argv[1]); + exp(posix_rand(), "posix_rand"); + exp(&random, "random"); + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 07:44:41
|
Revision: 1396 http://assorted.svn.sourceforge.net/assorted/?rev=1396&view=rev Author: yangzhang Date: 2009-05-07 07:44:39 +0000 (Thu, 07 May 2009) Log Message: ----------- - added vim doc - added dput.cf for ppa packaging Added Paths: ----------- configs/trunk/src/dput.cf configs/trunk/src/vim/doc/ps_color.txt configs/trunk/src/vim/doc/vimexplorer.txt Added: configs/trunk/src/dput.cf =================================================================== --- configs/trunk/src/dput.cf (rev 0) +++ configs/trunk/src/dput.cf 2009-05-07 07:44:39 UTC (rev 1396) @@ -0,0 +1,9 @@ +[my-ppa] +fqdn = ppa.launchpad.net +method = ftp +incoming = ~yaaang/ubuntu/ +login = anonymous +allow_unsigned_uploads = 0 + +[DEFAULT] +default_host_main = my-ppa Added: configs/trunk/src/vim/doc/ps_color.txt =================================================================== --- configs/trunk/src/vim/doc/ps_color.txt (rev 0) +++ configs/trunk/src/vim/doc/ps_color.txt 2009-05-07 07:44:39 UTC (rev 1396) @@ -0,0 +1,657 @@ +*ps_color.txt* PSC For Vim version 7.0 Last change: 23 Oct 2006 + + +PERSONAL COLOUR SWITCHER *ps_colour* *pscolor* + + +Author: Pan, Shi Zhu. <see vim online for my e-mail> + +============================================================================== +CONTENTS *psc* *psc-contents* + + 1. Contents.....................|psc-contents| + 2. PSC Overview.................|psc-overview| + 3. PSC Installation.............|psc-usage| + 4. PSC Options..................|psc-options| + 5. PSC under colour term .......|psc-cterm| + 6. PSC FAQ and Tips ............|psc-faq| + 7. PSC Release notes............|psc-release-notes| + 8. PSC Todo List................|psc-todo| + +For release notes, please see the header of ps_color.vim + +============================================================================== +PSC FEATURES OVERVIEW *psc-features* *psc-overview* + + Features ~ + + . PSC is firstly a color scheme which have both dark and light + background styles. + . It can have the same appearance in [cterm] as in [gui]. + . It is designed with gentle color to minimize fatigue of eye. + . It also works with other color schemes. + . Default foreground and background can easily be changed, it is more + configurable than most other color schemes + . Works with the optional tool reloaded.vim, can change the whole + color scheme in Hue,Saturation,Luminance color space. + + Design Concern ~ + + At the first glance this colour scheme may look pretty 'dull', don't be + afraid, this is quite normal. Bear in mind that a text editor is not + a photo album, if a text editor looks exciting you may not be able to + stare at it for a long time. + + Predefined Vim Syntax highlighting can be too colourful or contrasted so + that many programmers prefer to switch off the syntax highlighting at + work. That is not a good idea because you will lost the advantages of + syntax high-lighting. It is often the case that we have to work for + 300+ minutes, then I decide to do-it-myself. + + Many user-defined color schemes in vim.sf.net tend to achieve low + contrast by having a strong color-cast, i.e., looks blueish or + yellowish or reddish. This does look comfortable at first, however, + any type of color-cast will cause the eyes less sensitive for + particular color after a long-time work session, and that's no good to + health. + + Efforts had been made to ensure no color-cast for this scheme, all + elementary colours like RGB and CYMK are evenly used. Like TeX, + 'consistency' is the principle this color scheme based on. Default + values which hurt consistency are amended according to the vim script + syntax/hitest.vim + + There are 3 parameters to describe a color: Hue, Saturation and + Brightness. In this color scheme, the saturation is low and the + brightness are designed to be very close to each other in order not to + fatigue our eyes after a whole day's programming work. + + Portability ~ + + Different monitor settings led to different look. In this color + scheme, it is assumed that the monitor adjust at 6500k color + temperature with a good gamma curve. If you have a 9300k monitor or + if the gamma curve is not optimal, the appearance may be less + comfortable, use adobe gamma loader or similar tools to adjust + your monitor if your monitor do not have the option to change color + temperature and/or gamma curve. + + Needless to say, VI is an editor originally designed to do edit tasks + in a text terminal, and VIM is an improved version of VI. Its a shame + that a color scheme cannot have a satisfactory appearance in cterm. + The cterm compatibility should be considered high priority when + designing ViM color scheme. + + I had made much attempt to make support for 8-color terminals, + however, 8 colours is not enough to represent a color scheme. Finally + I end up making the cterm support for 16-color terminal. Have to say + sorry if the color scheme sucks in your 8-color terminal, I had tried + my best. More details about cterm please see |psc-cterm|. + + *psc-about-background* + About the Background ~ + + We have talked about off-white backgrounds, any background which is + not black, grey or white should be changed constantly in order not to + make the eyes less sensitive to particular color. i.e., you can use + blue background on Monday, red background on Tuesday, green background + on Wednesday, but if you use blue background everyday, that's no good + to your health. + + Now we talk about the brightness of the background. Why dark + background is preferred over others? There are many reasons, such as, + the monitor emits lower radiation for black background. You may have + lots of similar reasons... + + But I'll talk about something you may not know: +> + It is easier to distinguish foreground colours on a dark background + than on a light background. + + At the same time, it is easier to distinguish background colours on + a light background than on a dark background. + + We will mainly change foreground colours for syntax highlighting. +< + Hence, we can reduce the contrast and saturation of the color in + a dark-background scheme, while retain the readability. Schemes with + white background usually comes with higher contrast and saturation. + This is probably the most important reason that the color scheme is + designed to be dark-background instead of light one. + + Now we came to know, that change the foreground color is enough to + emphasis text in a dark background, while for a white background, we + need to change the font shape (bold or italic, etc.), or change the + background color to effectively emphasis the text. This is probably + the reason Vim default scheme has bold properties for highlighting + groups, because the default scheme is a light background one. + + No one knows what color scheme is best for you, except yourself. Try! + +============================================================================== +PSC INSTALLATION *psc-usage* + + Step 1, Enable the color scheme ~ + + To use PSC is simple, just put ps_color.vim into your + [runtimepath]/colors and append the line > + + colorscheme ps_color +< + to your |.vimrc|. The [runtimepath] can be any directory listed in + |vimfiles|, normally your $HOME/.vim in Unix or $HOME/vimfiles in + Windows. + + Step 2, Install the help document ~ + + The help document will be automatically installed when the colorscheme + be sourced the first time. If it is not, type :colo ps_color now. + + After successfully installed the help document, you can use > + + :help psc-options +< + to go to the following section. + +============================================================================== +PSC OPTIONS *psc-options* + + You can let these options in your ~/.vimrc, most options works for + both GUI and cterm, only some of them do not work for both. + + Options set using the 'let' command must present [BEFORE] the color + scheme been sourced. + + *psc_style* + Style ~ +> + let psc_style='cool' + let psc_style='warm' + let psc_style='default' + let psc_style='defdark' +< + This selects between styles of colors, + The 'cool' is the default, dark background. + The 'warm' is the alternative, light background scheme. + + See |psc-about-background| for more knowledge about the background, + and the differences of two style. + + The 'default' and 'defdark' refers to Vim system default color scheme. + Which are provided only for reference. + + Let psc_style to any string other than the above 4 will switch to the + specified color scheme. For example, let psc_style='desert' and then + activate the ps_color, the color scheme will be chosen according to + desert.vim color scheme. + + *psc_cterm_style* + Color Term Style ~ +> + let psc_cterm_style='cool' +< + This is exactly the same to psc_style, except that it only affects the + console version of vim in a color terminal, the 'warm' is not + available for cterm. + By default, it will be set to the same value as 'psc_style'. You can + change it if you want different style in cterm from gui. + + *psc_cterm_transparent* + Color Term Transparent ~ +> + let psc_cterm_transparent=1 +< + If this is set, cterm will use the transparent background. + i.e. the background will be the same as your terminal. + When background=dark, you should have a dark background for your + terminal, otherwise will result in poor readability. + + If this is reset (the default), cterm will use the Black background + anyway. + + *psc_fontface* + Font face ~ +> + let psc_fontface='plain' + let psc_fontface='mixed' +< + The Vim default behavior is the 'mixed', however, the mixed font style + in a dark colorscheme is not optimal. This color uses 'plain' for + 'cool' style, i.e. No texts are bold font. For 'warm', the default + is still 'mixed', If you want the mixed style in which the highlighted + statements are bold font, choose this. If you want all texts be + bold, choose 'plain' and specify a bold guifont or terminal font. + + In GUI, this option also works for other color schemes. You can + disable the bold font and use your favorite color scheme. See + |psc-faq-ffothers| for detail. + + *psc_inversed_todo* + Inversed Todo ~ +> + let psc_inversed_todo=1 +< + When set to 1, the TODO group will be dark background with light font, + Otherwise, the TODO group have light background with dark foreground. + Default is 0. + + *psc_use_default_for_cterm* + Use default for cterm (obsoleted)~ + + This option is Obsoleted, retained only for backward compatibility, + see |psc_cterm_style| for alternative. + + *psc_statement_different_from_type* + Statement different from type ~ +> + let psc_statement_different_from_type=1 +< + The Statement-group and Type-group are easy to distinguish, different + color for them are not necessary, I use similar color for S-group + & T-group in order not to make the screen too 'colorful', also this + saves a color name for cterm. But if you do want the Statement & Type + to be different color, try 'let statement_different_from_type=1' in + your .vimrc file, which is available only for GUI. Since the color + names in cterm is limited to 16 we cannot have too many different + colors in cterm. + Default is 0, i.e. they have very similar color. + + *psc-change-background* + Changing the Background color ~ + + You may prefer a black background over the dark one, and it is + possible to customize it, this may make life more interesting. To do + this is quite straight forward for GUI, just define the Normal + highlight in your .gvimrc, [AFTER] the color scheme has been sourced. + + For example: +> + highlight Normal guibg=#000000 +< + The #103040 will give a taste similar to oceandeep, #152535 for + hhazure, #303030 for desert, #404040 for zenburn... Replace #103040 + with any color you like. You can do the same to guifg foreground if + you are careful enough, remember this is only possible for GUI. + + You can do this to the NonText group also, for example. +> + highlight NonText guibg=#202020 +< + will give you a taste similar to most color schemes on vim.sf.net, in + which the NonText has a different background than Normal text. + However, this is only useful in GUI, in cterm, there are only + 8 background colors, so it is wise not to have a different color. + + If you want more variations, please try the optional utility + reloaded.vim, this optional utility provides an amazing level of + customization. + + Quick switching between warm and cold styles ~ + + Here is an example to define hot key of different style switching, + note that I had only given this example without actually define it. + You can choose to define it in .vimrc or anyway you prefer. +> + nnoremap <Leader>pc :let psc_style='cool'<CR>:colo ps_color<CR> + nnoremap <Leader>pw :let psc_style='warm'<CR>:colo ps_color<CR> +< + Alternatively, you can use the capitalized :Colo command, like + :Colo cool or :Colo warm + +============================================================================== +PSC WITH CTERM *psc-cterm* + + Colour Term ~ + + The cterm color is designed mainly in these terminals: +> + 1. Cygwin bash shell in NT command prompt box + 2. XTERM and RXVT + 3. Other color terminals which have at least 16 colors +< + *psc-cterm-nt* + In Windows NT Prompt console you can change the exact value of each + color, so you can have the same color with your GUI version of Vim, + for 'cool' color style you just change the color according to the + |psc-cterm-color-table|, for how to redefine the color of Windows NT + prompt console please see Windows Help. + + NT Cygwin bash shell console supports 16 foreground colors by add bold + attribute to 8 color, the cterm=bold specifies which should be bright + color, so totally the 16 color foreground is available, but color + name DarkXXX and LightXXX are the same. + + The pre-configured Cygwin.lnk is available for download on my web page + for Vim, but the site seems down, and the my site would not be on + recently, you may need to change colors in the Properties menu... + + Cygwin is highly recommended for Vim user if you are using Windows NT + based systems (e.g. NT 4.0, Win2k, WinXP, Win2003, etc). But Cygwin is + not that versatile under Windows 95/98/ME. I'm not sure whether this + works for DOS DJGPP or Windows 95 console version of Vim because + I don't have the system, in case you encountered problem please + contact me, if you like. + + *psc-cterm-xterm* + XTERM is a much more feature-rich terminal than Windows Console so the + support is much better. Normally, add the following recommend line + into your .Xdefaults and you can achieve the same color as in GUI + version, currently only works for XTERM and RXVT. + + However, most modern GUI terminal emulators do not read .Xdefaults + at all, in that case you will have to set the color manually according + to |psc-cterm-color-table|. + + In case your term supports .Xdefaults, Add the following in it: +> + XTerm*color0: #000000 + XTerm*color1: #800000 + XTerm*color2: #008000 + XTerm*color3: #d0d090 + XTerm*color4: #000080 + XTerm*color5: #800080 + XTerm*color6: #a6caf0 + XTerm*color7: #d0d0d0 + XTerm*color8: #b0b0b0 + XTerm*color9: #f08060 + XTerm*color10: #60f080 + XTerm*color11: #e0c060 + XTerm*color12: #80c0e0 + XTerm*color13: #f0c0f0 + XTerm*color14: #c0d8f8 + XTerm*color15: #e0e0e0 + XTerm*cursorColor: #00f000 + + ! The following are recommended but optional + XTerm*reverseVideo: False + XTerm*background: #202020 + XTerm*foreground: #d0d0d0 + XTerm*boldMode: False +< + There is an assumption that your RXVT or XTERM supports 16 colors, + most RXVTs and XTERMs support this, if yours do not, get a source of + RXVT and recompile it. + + Sometimes the color mode are not recognized well, or you do not want + bright foreground be bold. If this is the case, add the following in + your .vimrc (before the color scheme been sourced) +> + if &term=='xterm' " Change 'xterm' to your term name if necessary + set t_Co=16 + endif +< + If the t_Co=16 have problem, set t_Co=8 and :colo ps_color again. + and vice versa. + + My rxvt works well with t_Co=16: > + Rxvt v2.7.10 - released: 26 MARCH 2003 + Options: + XPM,transparent,utmp,menubar,frills,linespace,multichar_languages, + scrollbars=rxvt+NeXT+xterm,.Xdefaults +< But I've know that my rxvt v2.6.4 in another machine has problem with + t_Co=16, if that is the case, set t_Co=8 instead. + + *psc-cterm-others* + For other terminals, you can manually set the color according to the + following table + + Hints for Manually set the color (for 'cool' style only): + *psc-cterm-color-table* + Color name Hex value Decimal value (r,g,b)~ + 0 Black = #000000 0,0,0 + 4 DarkBlue = #000080 0,0,128 + 2 DarkGreen = #008000 0,128,0 + 6 DarkCyan = #a6caf0 166,202,240 + 1 DarkRed = #800000 128,0,0 + 5 DarkMagenta = #800080 128,0,128 + 3 DarkYellow = #d0d090 208,208,144 + 7 Grey = #d0d0d0 208,208,208 + 8 DarkGrey = #b0b0b0 176,176,176 + 12 Blue = #80c0e0 128,192,224 + 10 Green = #60f080 96,240,128 + 14 Cyan = #c0d8f8 192,216,248 + 9 Red = #f08060 240,128,96 + 13 LMag. = #f0c0f0 240,192,240 + 11 Yellow = #e0c060 224,192,96 + 15 White = #e0e0e0 224,224,224 + + *psc-cterm-incompatible* + If your color terminal does only have 8 colors and cannot achieve 16 + colors with cterm=bold, you may want to switch to other color schemes + to gain more readability. Anyway, you can specify in your .vimrc to + use different color scheme under different consoles and GUI. + For example: +> + let psc_cterm_style = 'foobarcolor' + let psc_style = 'cool' + colo ps_color +< + The 'foobarcolor' means the color scheme you want to choose, such as + 'desert', I recommend to try vim default schemes 'default' and + 'defdark' before experience others. + +============================================================================== +PSC FAQ AND TIPS *psc-faq* *psc-tips* +> + Q: What is meant by `PS' ? +< + A: PS means: PostScript, PhotoShop, PerSonal, ..., or anything you can + imagine and anything you want it do be. +> + Q: How to obtain the same appreance as gui in color term? +< + A: This need some work around, see |psc-cterm| for details. + Generally speaking, you should ensure your color term has support + for 16 foreground colors, and each color is customizable. + + *psc-faq-ffothers* > + Q: How to use psc_fontface with other colorschemes? +< + A: Make sure you had sourced :colo ps_color in your .vimrc, then you + can use the Capitalized :Colo instead of :colo + e.g. you want to use 'murphy', just type :Colo murphy after you + sourced the ps_color, the 'defdark', 'cool', 'warm' can also be + used here. +> + Q: I updated from v2.0 to v2.3 or above, why the cterm color scheme + for Comment is different? +< + A: The color map of DarkYellow and Yellow have been exchanged, + You need to reconfigure your terminal to meet the change, + see |psc-cterm-color-table| for guide, or if you are using xterm + compatible terminal, just update the .XDefaults according to + |psc-cterm-xterm|. +> + Q: What do you mean by 'Vanilla Windows'? +< + A: People often argue that Windows is not a REAL operating system. + Well, I agree this, but only for vanilla windows. i.e. with no + plug-ins installed. Vanilla windows is a very limited platform, + since it is not POSIX compliant. + + There are currently many working around to make Windows POSIX + Compliant, do you still mind which OS to use when it is POSIX + Compliant? I don't. If you installed Cygwin kernel in your + NT-based Windows, the Windows will be more or less POSIX compliant + and you can use it in the same way as you use any Unix, BSD, + Solaris, Linux, XWindow, etc... What is more, Cygwin is not the + only kernel which makes Windows POSIX Compliant, make a google + search and you will find many alternatives. +> + Q: How to change the Normal background color? Why don't you use + different background for NonText group? +< + A: This is for compatibility, since we have to use only 8 colors as + background in a color terminal. For GUI you can change this, see + |psc-change-background| for details. +> + Q: I updated from 2.81- to 2.82+, why the default background changed? +< + A: This is for Bram's guideline, that dark schemes with black + background has too much contrast. + + However, you can change it back. See |psc-change-background| for + details. +> + Q: Something changed/doesn't work on 3.00... +< + A: See 3.00 Release note. + +============================================================================== +PSC RELEASE NOTES *psc-release-notes* + + 3.00 Release Note: ~ + + GUI: now we accept the &background instead of the "warm" and "cool" + style value. So the "warm" and "cool" for psc_style are silently + ignored, all users must set the 'background' option manually before + :colo ps_color. + + Since this is an incompatible change, I bump the version to 3.00 + + CTERM: if psc_style set to 'warm', the v2.90 before will set the style + to 'cool', the 3.00 will set the style to 'default' since the + background change are eliminated in 3.00. So basically, if you had the + background=light in your color terminal, :color ps_color will have + little effect. + + Since the background setting can be wrong in cterm, the transparent + background are not the default. We added |psc_cterm_background| option + to change the bahavior. + + Checked spell with spelllang=en, changes in typos for document. + + 2.95 Release Note: ~ + + GUI: Make many foregrounds and backgrounds transparent, in most cases you + will not notice any difference. But you may feel better in some rare + case. + + CTERM: if your terminal has a transparent background, then we can have + the transparent background in vim. Note that the terminal color scheme + has to be dark-background for maximum portability. If you have + a light-background terminal emulator and want to use ps_color color + scheme, please keep v2.90, or change your terminal background color to + a dark one. + + 2.90 Release Note: ~ + + Upon the release of Vim 7, many new highlight groups have been added. + + A style has been tuned a little to increase contrast. + + + 2.83 Release Note: ~ + + This is an identical version, but my e-mail address changed. + + + 2.82 Release Note: ~ + + Fixed bug with the reversed group for the Vim default, or other + schemes. + + Fixed bug with the Diff mode fg mistaken as fg. + + Shrink the script a lot to improve load performance, moved the release + notes into document. + + Change the default gui background color to #202020 (Dark Grey) + + + 2.81 Release Note: ~ + + Provided a separate utility reloaded.vim to fine tune the GUI color + scheme based on Hue, Saturation and Brightness(Luminance). + + Added some groups to meet the need of reloaded.vim, no essential + change. + + 2.8 Release Note: ~ + + Bugfix : when psc_style=='mixed', the visual got reversed wrong. + + 'mixed' is now the default for 'warm' style. + + changed the function name to lower case. + + removed pre-2.0 compatibility, (the non-psc version of s-d-f-t). + + Added variable psc_cterm_style, see |psc_cterm_style| + + Added group Underline + + Tuned the function call. + + 2.7 Release Note: ~ + + Now it is possible to change the Background, + see :h psc-change-background for details. + + Linked the Tag group to Identifier. + + NonText as Notice is not good for 'warm', changed to Constant. + + Added links for the most popular plug-ins: taglist, calendar + + Tuned the 'Statement' color when different from Type (gui only). + + Re-adjusted cterm scheme according to syntax/hitest.vim + + The 'defdark' style for cterm is not functioning, fixed. + + Many 'cosmetic' changes, makes no difference for functionality. + + Use of DrChip's help extractor to auto-install help document. + + Added command define, :Colo + + 2.6 Release Note: ~ + + As stated in the v2.3, the only 'todo' thing seems to be the 'warm' + style, now in this version I had been working on it. + + There also are some minor fixes for the document, to be more friendly + for new readers. + + The 'StatusLine' of 'cold' style is modified by mistake in the v2.3, + this time the bug is fixed. + + The 'Directory' in GUI 'cold' style is different from 'cterm' one, + now fixed. + + 2.3 Release Note: ~ + + This is an incompatible update, main changes are in 'cterm'. + A new group 'SignColumn' had been added, new links added for engspchk + v52, hundreds of typos fixed in the document, thanks to the engspchk. + + The support for 8-color cterm is slightly better now, but the mappings + of the DarkYellow and Yellow are exchanged, you need to update the + .Xdefaults or your terminal configuration before apply this update if + you are using v2.0. Guide for redefinition the color value is + available in the document, make sure you had updated the ps_color.txt, + then see |psc-cterm-color-table| + + 2.0 Release Note: ~ + + There have been great enhancement since this version, so I'd choose to + bump the version number to 2. This version comes with Vim online help, + if you had installed ps_color.txt, you can see for details in + |pscolor| + + n/a Release: ~ + + Initial upload, can be called as v1.8 + + +============================================================================== +PSC TODO LIST *psc-todo* + + . Fix the remain bugs. + . Follow the new Vim versions for new added highlighting group + . This cannot work in Vim Small and Tiny mode, and will never work! + +============================================================================== + +vim:tw=78:ts=8:noet:ft=help:fo+=t:norl:noet: Added: configs/trunk/src/vim/doc/vimexplorer.txt =================================================================== --- configs/trunk/src/vim/doc/vimexplorer.txt (rev 0) +++ configs/trunk/src/vim/doc/vimexplorer.txt 2009-05-07 07:44:39 UTC (rev 1396) @@ -0,0 +1,542 @@ +*VimExplorer* A powerful file manager v0.98 + + + VimExplorer Reference Manual + by Ming Bai (mbbill AT gmail.com) + + +============================================================================== +CONTENTS *VimExplorer-contents* + +1. Intro.......................................|VimExplorer-start| +2. Functionality...............................|VimExplorer-functionality| + 2.1 Tree Panel Hotkeys.....................|VimExplorer-treehotkey| + 2.2 File Panel Hotkeys.....................|VimExplorer-filehotkey| + 2.3 Commands...............................|VimExplorer-commands| +3. Directory Browsing..........................|VimExplorer-browse| + 3.1 Tree Browsing..........................|VimExplorer-treebrowse| + 3.2 File Browsing..........................|VimExplorer-filebrowse| + 3.3 Forward and Backward...................|VimExplorer-forbackward| + 3.4 Favorites..............................|VimExplorer-favorite| + 3.5 Temp Marks.............................|VimExplorer-tempmark| +4. Marks.......................................|VimExplorer-mark| + 4.1 Single File Marks......................|VimExplorer-marksingle| + 4.2 Visual Marks...........................|VimExplorer-markvisual| + 4.3 Regexp Marks...........................|VimExplorer-markregexp| +5. File operations.............................|VimExplorer-fileoperation| + 5.1 Create.................................|VimExplorer-new| + 5.2 Move...................................|VimExplorer-move| + 5.3 Delete.................................|VimExplorer-delete| + 5.4 Diff...................................|VimExplorer-diff| + 5.5 Search.................................|VimExplorer-search| + 5.6 Other Operations.......................|VimExplorer-otherfileopt| +6. Other Functionalities.......................|VimExplorer-otherfuncs| +7. Customization...............................|VimExplorer-customize| + 7.1 Normal Options.........................|VimExplorer-custnormal| + 7.2 Hotkey Customization...................|VimExplorer-custhotkey| + 7.3 Command Customization..................|VimExplorer-custcommand| +8. The Author..................................|VimExplorer-author| +9. Problems and Fixes..........................|VimExplorer-problems| +10. Changelog...................................|VimExplorer-changelog| +11. TODO........................................|VimExplorer-todo| + + +============================================================================== +1. Intro *VimExplorer-start* + +What is VimExplorer ? +VimExplorer is a file manager, it can do a lot of file operations such as +copy, delete, move, preview, search and so on. Also it has a variety of other +capacities and customization abilities. + +You can start VimExplorer by the following command: +> + :VE +< +Then it will ask you for the starting directory, default is the current path. +> + VimExplorer (directory): /home/username/ +< +You can change it to some other directories or just push "Enter" to start it. + +The second approach to start VimExplorer: +> + :VE [directory] +< +Example: +> + :VE /usr/src/ +< +Now, VimExplorer will start using the path '/usr/src/'. When you are typing +the path, <tab> and <ctrl-d> will help you to complete the path automatically. +After all of these operations, you can see a new tab which has two panels +within it, one is the "Tree Panel" and the other is "File Panel". From now you +will have a happy journey using the powerful file manager. + + +============================================================================== +2. Functionality *VimExplorer-functionality* + +2.1 Tree Panel Hotkeys *VimExplorer-treehotkey* + +Member of |VEConf_treeHotkey|, refer to section 7.2 . + +Mapping Key Description~ +help ? Help. +toggleNode <cr> Open/Close/Switch to current node. +toggleNodeMouse <2-LeftMouse> Open/Close/Switch to current node. +refresh r Refresh the tree panel. +favorite f View favorite folder list. +addToFavorite F Add the folder under cursor to + favorite list. If no path under + cursor, use current working path. +browseHistory b View browse history. +toggleFilePanel t Toggle the file panel. +toUpperDir <bs> Go to upper directory. +switchPanel <c-tab> Switch to File Panel. +gotoPath <c-g> Change to another path. +quitVE Q Quit VimExplorer. + +2.2 File Panel Hotkeys *VimExplorer-filehotkey* + +Member of |VEConf_fileHotkey|, refer to section 7.2 . + +Mapping Default Description~ +help ? Help. +itemClicked <cr> Enter the directory or open the file + by default association. +itemClickMouse <2-LeftMouse> Enter the directory or open the file + by default association. +refresh r Refresh. +toggleTreePanel t Toggle the Tree Panel. +toggleModes i Toggle file sort mode (type/data/file + extension). +newFile +f Create a new file. +newDirectory +d Create a new directory. +switchPanel <c-tab> Switch to the Tree Panel. +quitVE Q Quit VimExplorer. +toggleHidden H Toggle show hidden files.(files start + with '.') +search g/ Search. +markPlace m{a-z} Put current path to register(a-z). +gotoPlace '{a-z} Jump to path in register(a-z). +viewMarks J View path in register. +toUpperDir <bs> Go to upper directory. +gotoForward <c-i> Forward. +gotoBackward <c-o> Backward. +favorite f View favorite folder list. +addToFavorite F Add the folder under cursor to + favorite list. If no path under + cursor, use current working path. +browseHistory b View browse history. +gotoPath <c-g> Change to another path. +rename R Rename the file under cursor. +yankSingle yy Copy file under cursor. +cutSingle xx Cut file under cursor. +showYankList yl Show clipboard. +deleteSingle dd Delete file under cursor. +openPreview u Preview. +closePreview U Close the preview panel. +toggleSelectUp <s-space> Move the cursor up and mark/unmark the + file under cursor. +toggleSelectDown <space> Mark/unmark the file under cursor and + move the cursor down. +markViaRegexp Mr Mark via regular expression. +markVimFiles Mv Mark all vim files. +markDirectory Md Mark all directories. +markExecutable Me Mark all executable files. +clearSelect Mc Clear all marks. +deleteSelected sd Delete marked files. +yankSelected sy Copy marked files. +cutSelected sx Cut marked files. +tabViewMulti se Edit every marked file in separate + tabs. +paste p Paste. +diff2files = Diff two files. +tabView e Edit file in new tab. +openRenamer ;r Open Renamer (Note 1) +startShell ;c Start a shell from current path. +startExplorer ;e Start another file + manager(nautilus,konquer,explorer.exe). + +Visual Mode Hotkeys~ +visualSelect <space> Mark files. +visualDelete d Delete files. +visualYank y Copy files. +visualCut x Cut files. +tabView e View files in new tabs. + +2.3 Commands *VimExplorer-commands* +> + VE +< +Start VimExplorer. + +> + VEC +< +Close VimExplorer, Hotkey |Q| has the same ability. + +============================================================================== +3. Directory Browsing *VimExplorer-browse* + +3.1 Tree Browsing *VimExplorer-treebrowse* + +Press "Enter" on one tree node will change the path and add the new path to +browse history. By default, if a directory has it's own child directories, |+| +will be displayed before it's name, and It will cause a little performance +lost. If you don't need this feature ,set the following variable to zero can +disable it. +> + let VEConf_showFolderStatus = 0 +< +There are some differences between win32 and other platforms. In win32, there +are several root nodes (such as C:\,D:\), but one root node (/) in other +platforms. + +3.2 File Browsing *VimExplorer-filebrowse* + +The file panel consist of two parts: the path in the top and the following +file list. Every line of the file list consist from the following regions: + +[*] {file-name} [file-size] {permission} {modify-time} + +The file panel can sort by type, file name and date. Hotkey |i| is used to +cycle between these modes. Default sort mode controlled by following variable: +> + VEConf_filePanelSortType + +< +See Customization section for more details. + +3.3 Forward and Backward *VimExplorer-forbackward* + +When using "Enter" switch to an new folder, the path will be add to browse +history. Then you can use |<c-o>| and |<c-i>| to go backward and forward. +Hotkey |b| is used to list all browse history, select by number or mouse can +take you directory to that path. + +By default, the depth of browse history is 100. Controled by this variable: +> + VEConf_browseHistory +< + +3.4 Favorites *VimExplorer-favorite* + +The favorite folder list is saved to the file $HOME/.ve_favorite . It will be +updated when new folder is added to favorite by hotkey |F|. The format of +".ve_favorite" is very simple: every line is a path, so edit it is quite +easy. + +3.5 Temp Marks *VimExplorer-tempmark* + +Just like the favorites, |ma| put current path into register 'a', and |'a| can +jump to the path. |J| is used to list every non empty register. All paths in +register will disappear after VimExplorer exists. + +============================================================================== +4. Marks *VimExplorer-mark* + +The simplest way is to press <space> upon a file. There will be a '*' before +marked files and also be displayed in a different color. +There are three way to mark files: + +4.1 Single File Marks *VimExplorer-marksingle* + +<space> Invert selection, move the cursor down. +<s-space> Move the cursor up, then invert selection. +Just like most of vim commands, 5<space> will mark 5 files start from current +cursor. + +4.2 Visual Marks *VimExplorer-markvisual* + +<space> in visual mode will invert selected these files. + +4.3 Regexp Marks *VimExplorer-markregexp* + +Hotkey: |Mr| +Only the file name is the target of regexp match. Example: +> + Mark file (regexp): ^abc.*\.vim$ +< +It will mark all vim scripts start with abc. The following functionalities is +derived from this feature: +|Mv| mark all vim scripts. +|Me| mark all executable files. +|Md| mark all directories. +and |Mc| to clear all marks. + +============================================================================== +5. File Operations *VimExplorer-fileoperation* + +5.1 Create *VimExplorer-new* + +|+f| and |+d| is used to create new files and directories. + +5.2 Move *VimExplorer-move* + +There are several hotkey used to copy/cut files: +|yy| and |sy| in normal mode ,|y| in visual mode is to copy file. +|xx| and |sx| in normal mode ,|x| in visual mode is to cut file. +|p| paste file. +Note that the clipboard is shared between all VimExplorers ,you can cut in one +VE tab and paste in another. +If you want to view the clipboard, |yl| can be help. + +5.3 Delete *VimExplorer-delete* + +|dd| in normal mode and |d| in visual mode. Feel good? + +5.4 Diff *VimExplorer-diff* + +|=| is used to diff 2 files, so make sure you have selected 2 files before +using this command. + +5.5 Search *VimExplorer-search* + +Just like / ,but the pattern here is not the regexp in vim, it will be +expended by shell. + +5.6 Other Operations *VimExplorer-otherfileopt* + +|e| |R| |u| and so on ... Refer to section 2.2 + +============================================================================== +6. Other Functionalities *VimExplorer-otherfuncs* + +|;r| |;c| |;e| and so on ...Rever to section 2.2 + +============================================================================== +7. Customization *VimExplorer-customize* + +7.1 Normal Options *VimExplorer-custnormal* + +Common Options~ + +|g:VEConf_systemEncoding| It controls the encoding of vim calling + function system(). If your system encoding + is different from '&encoding', set this + value to system encoding. Example: let + g:VEConf_systemEncoding = 'utf-8' + ,Default: '' (empty) + +|g:VEConf_win32Disks| The default value is all 26 volumes. Set this + value to fit your system can increase the + startup speed. If you are not using + Microsoft Windows, ignore it. Example: + let VEConf_win32Disks = + ["A:","B:","C:","D:"] + +|g:VEConf_browseHistory| Depth of browse history. Default: 100 + +|g:VEConf_previewSplitLocation| Split location of preview panel. Optional + parameters are: + "belowright","topleft","leftabove","botright". + Default: "belowright" + +|g:VEConf_showHiddenFiles| Show hidden files, 1: show,0: hide. Default: 1 + +|g:VEConf_externalExplorer| Name of the external file explorer. You can + set this value according to you system. + Default: "explorer.exe"(win32) "nautilus" + (gnome) + +|g:VEConf_sortCaseSensitive| 0: not case sensitive 1: case sensitive + Default: 1 + +|g:VEConf_favorite| Favorite folder file name. Always stored in + $HOME. Default: ".ve_favorite" + +|g:VEConf_overWriteExisting| Ask when over write existing files. + 0: ask 1: always over write 2: always + not over write Default: 0 + +|g:VEConf_usingKDE| If set to 1, use "kfmclient" +|g:VEConf_usingGnome| If set to 1, use "gnome-open" + +Tree Panel Options~ + +|g:VEConf_showFolderStatus| It controls show '+' before the folders which + have their own child folders. If it is set + to 1, every folder will have a '+'. + Default: 1 + +|g:VEConf_treePanelWidth| Width of tree panel. Default: 30 + +|g:VEConf_treePanelSplitMode| Split mode of tree panel. Default: "vertical" + +|g:VEConf_treePanelSplitLocation| Split location of tree panel, Optional + parameters: "belowright" , "topleft" , + "leftabove" , "botright", Default: + "leftabove" + +|g:VEConf_treeSortDirection| Sort direction. 1: A-Z 0: Z-A. Default: 1 + +File Panel Options~ + +|g:VEConf_fileGroupSortDirection| Sort direction. 1: A-Z 0: Z-A, Default: 1 + +|g:VEConf_fileDeleteConfirm| Confirm when deleting a file. 1: confirm 2: + no confirm. Default: 1 + +|g:VEConf_filePanelWidth| Width of file panel. Default: 40 + +|g:VEConf_filePanelSplitMode| Split mode of file panel. Default: "vertical" + +|g:VEConf_filePanelSplitLocation| Split location of file panel, Optional + parameters: "belowright" , "topleft" , + "leftabove" , "botright" ,Default: + "leftabove" + +|g:VEConf_filePanelSortType| File sort type. 1: sort by name 2: sort by + time 3: sort by type, Default: 3 + +|g:VEConf_showFileSizeInMKB| 1: Show file size in MKB format. 0: always + show file size in byte. + +|g:VEConf_filePanelFilter| Filter of the file panel, which will be + passed to glob() function. Example: + let g:VEConf_filePanelFilter = '*.txt' + +7.2 Hotkey Customization *VimExplorer-custhotkey* + +All user defined hotkeys are controlled by the two dicts: +|g:VEConf_treeHotkey| and |g:VEConf_fileHotkey| +Example: +> + let g:VEConf_treeHotkey = {} + let g:VEConf_treeHotkey.help = '??' + let g:VEConf_treeHotkey.quitVE = 'qq' + let g:VEConf_treeHotkey.switchPanel = '<s-tab>' +< +All definable hotkeys and their default bindings refer to section 2 . + +7.3. Command Customization *VimExplorer-custcommand* + +VimExplorer supports three types of command interface: +single file hotkeys and actions, multi file hotkeys and actions and normal +hotkeys and actions. +They are controlled by these variables: + + |VEConf_singleFileActions| |VEConf_singleFileHotKeys| + + |VEConf_multiFileActions| |VEConf_multiFileHotKeys| + + |VEConf_normalActions| |VEConf_normalHotKeys| + +All of them are dicts. Example: +> + let VEConf_normalActions = {} + let VEConf_normalHotKeys = {} + let VEConf_normalHotKeys['test1'] = 'T1' + function! VEConf_normalActions['test1']() + Renamer + endfunction +< +"test1" is the key. VimExplorer will bind the hotkey and corresponding actions +automatically. +> + let VEConf_singleFileActions = {} + let VEConf_singleFileHotKeys = {} + let VEConf_singleFileHotKeys['test2'] = 'T2' + function! VEConf_singleFileActions['test2'](path) + call VEPlatform.system("notepad.exe " . VEPlatform.escape(a:path)) + endfunction +< +Here, parameter "path" is the path of file under cursor. +> + let VEConf_multiFileActions = {} + let VEConf_multiFileHotKeys = {} + let VEConf_multiFileHotKeys['test3'] = 'T3' + function! VEConf_multiFileActions['test3'](fileList) + for i in a:fileList + call VEPlatform.start("nautilus " . i) + endfor + endfunction +< +Parameter "fileList" consists of all paths of marked files. +In addition, VimExplorer provides some platform independent functions: +> + VEPlatform.start(path) + VEPlatform.system(cmd) + VEPlatform.copyfile(filename,topath) + VEPlatform.search(filename,path) + VEPlatform.deleteSingle(path) +< +These functions can be used in user defined actions. + + + + +============================================================================== +8. The Author *VimExplorer-author* + +If you found a bug, or have some suggestions , mail me. + +mail: mbbill<AT>gmail<Dot>com + +============================================================================== +9. Problems and Fixes *VimExplorer-problems* + + *VimExplorer-p1* +P1. Case sensitive in Win32. + At present, the path in win32 is case sensitive. Pay attention to this + when starting VE, editing the favorite list or using <c-g> to change + path. A good suggestion is using <tab> or <ctrl-d> to complete path + automatically. + + *VimExplorer-p2* +P2. 'wildignre' option cause some files disappeared. + If 'wildignore' is not empty, glob() function will not return files + matching the file pattern listed in it, then you may find some files + disappeared in the file panel. + + + +============================================================================== +10. Changelog *VimExplorer-changelog* + +0.95 + - Initial release. + +0.96 + - Bug fix: VE_normalAction not found. + +0.97 + - Change the behaviour of hotkey 'F', now it adds the path under cursor to + favorite list. If no path under cursor, use current working path + instead.(Thanks to Vincent Wang) + - Bug fix: escape ' %#' for path. + - Add options |g:VEConf_usingKDE| and |g:VEConf_usingGnome| for starting + program in *nix environment. + - Check if the script is already loaded, thanks to Dennis Hostetler. + - Change default g:VEConf_systemEncoding to '' (empty). + - Bug fix: favorite selection out of range. +0.98 + - Add option VEConf_filePanelFilter. + - Bug fix: Escape <space> in command 'e' 'se' 'u' and '='. + - Bug fix: 'Cut' and 'Paste' command causes file lost. + - Change the default hotkey 'M' and 'B' to 'm','J'. + - Change forward and backward hotkey to |<c-o>| and |<c-i>|(<tab>). + - Change hotkey |<tab>| to |<c-tab>|. + - Change hotkey |mr| |mv| |md| |me| |mc| to |Mr| |Mv| |Md| |Me| |Mc|. + - When GUI is running, use confirm() to pop a dialog instead of input(). + +============================================================================== +11. TODO *VimExplorer-todo* + - More clipboard. + - Diff files in different directories. + - Remember the cursor place when switch between directories. + - Two panel mode, just like TotalCommand. + - Diff directories. + - Browse via e.g. FTP, SCP ... directorys on a server. + +============================================================================== +Note 1: +Renamer is a good plugin used to rename files. The author is John Orr. It can +be found here: +http://www.vim.org/scripts/script.php?script_id=1721 + + + + vim:tw=78:ts=8:ft=help:norl: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 07:43:35
|
Revision: 1395 http://assorted.svn.sourceforge.net/assorted/?rev=1395&view=rev Author: yangzhang Date: 2009-05-07 07:43:33 +0000 (Thu, 07 May 2009) Log Message: ----------- - added fillcode - set indentation for some languages - added sample config for paragraph start and separator - added a default font - tweaked the font Modified Paths: -------------- configs/trunk/src/emacs/yang.el Added Paths: ----------- configs/trunk/src/emacs/fillcode.el Added: configs/trunk/src/emacs/fillcode.el =================================================================== --- configs/trunk/src/emacs/fillcode.el (rev 0) +++ configs/trunk/src/emacs/fillcode.el 2009-05-07 07:43:33 UTC (rev 1395) @@ -0,0 +1,674 @@ +;;; fillcode.el --- Fillcode minor mode +;; +;; Fillcode +;; http://snarfed.org/space/fillcode +;; Copyright 2005-2007 Ryan Barrett <fil...@ry...> +;; +;; This minor mode enhance the fill functions when in source code major modes, +;; such as c-mode, java-mode, and python-mode. Specifically, it provides a new +;; fill function that intelligently fills some parts of source code, like +;; function calls and definitions, if the language mode's fill function +;; doesn't already. +;; +;; M-x fillcode-mode toggles fillcode-mode on and off in the current buffer. +;; +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; A copy of the GNU General Public License can be obtained at +;; http://www.gnu.org/licenses/gpl.html or from the Free Software Foundation, +;; Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +(defconst fillcode-version "0.7.1") + +(require 'cl) ; for the case macro + +(require 'cc-bytecomp) ; for c-in-literal and c-literal-limits +(cc-require 'cc-engine) + +; gnu emacs supports optional forms as the last arguments to +; define-minor-mode; they're evaluated when the minor mode is enabled or +; disabled. this is really nice, but xemacs' define-minor-mode doesn't have +; it, so i have to advise the fillcode-mode function instead (below). +(define-minor-mode fillcode-mode + "Toggle fillcode mode. +With no argument, this command toggles the mode. Non-null prefix argument +turns on the mode. Null prefix argument turns off the mode. + +Fillcode mode can intelligently fill some parts of source code, like function +calls and definitions, in many languages. + +To see what version of fillcode you are running, enter `\\[fillcode-version]'. + +For more information, see http://snarfed.org/space/fillcode" + nil ;; initial value + " Fillcode" ;; mode line indicator + nil) ;; keymap + + +(defun fillcode-version () + "Echo the current version of fillcode mode in the minibuffer." + (interactive) + (message "Using fillcode mode version %s" fillcode-version)) + +(defadvice fillcode-mode (after fillcode-mode-setup-and-teardown) + ;; run these when fillcode-mode is enabled or disabled. the fillcode-mode var + ;; is set before these run. + (make-local-variable ;; The primary fill function. Fillcode only + 'fillcode-wrapped-fill-function) ;; runs if this returns nil. + (make-local-variable 'fill-paragraph-function) + + (if fillcode-mode + ; this runs when fillcode is enabled... + (progn + (if (not (eq fill-paragraph-function 'fillcode-fill-paragraph)) + (setq fillcode-wrapped-fill-function fill-paragraph-function) + (setq fillcode-wrapped-fill-function nil)) + (setq fill-paragraph-function 'fillcode-fill-paragraph) + (ad-activate 'c-fill-paragraph)) + + ; ...and this runs when it's disabled. + (progn + (if (eq fill-paragraph-function 'fillcode-fill-paragraph) + (setq fill-paragraph-function fillcode-wrapped-fill-function)) + (ad-deactivate 'c-fill-paragraph)))) + +(ad-activate 'fillcode-mode) + + +(defadvice c-fill-paragraph (around fillcode-if-in-code) + "If in fillcode-mode, fill code when in `cc-mode'. + +`cc-mode' replaces `fill-paragraph' with its own function, `c-fill-paragraph', +which only calls fill-paragraph if it's inside a comment or string literal, and +narrows to that comment or string literal. Fillcode operates on code itself, so +it needs a chance to run (without narrowing!), which this advice provides." + (when fillcode-mode + (let ((fill-paragraph-function nil)) + ad-do-it) + (fillcode-fill-paragraph arg))) ; arg is c-fill-paragraph's arg + + +(defgroup fillcode nil + "Fill code" + :group 'fill) + +(defcustom fillcode-fill-points + (list + ";[^;]" + ",[^,]" + "<<[^<]\\|>>[^>]" ; iostream operators + "&&[^&]\\|||[^|]" ; boolean operators + (concat "[<>!=]=[^=]\\|" ; binary operators + ; less than (<) and greater than (>) are special, since they're + ; used in so much other syntax - templates, ->, <<, >>, <=, >=. so + ; we specifically check for extra -, <, >, and = characters, and + ; for whitespace, so that we only fire on the actual operators. + "\\s-<\\s-\\|" + "\\s->\\s-") + (concat "/[^=]\\|" ; arithmetic operators + ; single asterisks are used for pointers in c and c++, so to be + ; conservative, they're only fill points if they're surrounded by + ; whitespace. yes, this means that expressions like foo = bar*baz; + ; won't be normalized or filled correctly. + "\\s-\\*\\s-\\|" + ; minus signs are only fill points if they're not being used as a + ; negative sign or pre/post-decrement. approximate this by checking + ; if they're surrounded by whitespace. (it's a bad approximation.) + "\\s--\\s-\\|" + ; same with plus signs, to avoid pre/post-increments. + "\\s-\\+[^+=]") + "[|~^][^&|=]" ; bitwise operators + "[([][^]})({[]" + "\\s-{[^({[]" + ) + + "A list of regular expressions used to find fill points. +A fill point is a point in an expression where the expression can be filled (ie +wrapped). This list contains regular expressions that identify fill points. +When fillcode runs, it uses this list, along with `fill-column', to determine +where to fill. + +The list is ordered by precedence. The first regexp contains fill points that +fillcode prefers to fill at first, if possible. If none of them are found, +fillcode tries the next regexp, and so on. + +Each regexp match must include one character *after* the fill point ends. + +You may modify this to allow fillcode to handle new languages. + +Note that the single = (assignment) operator and < and > operators are +unfortunately absent." + :type '(repeat string) + :group 'fillcode) + +(defun build-re (re-list) + "Connect a list of regexps with |s to build a single regexp, and return it." + (mapconcat 'identity re-list "\\|")) + +(defcustom fillcode-before-fill-point-re + (build-re + '("<<." ">>.")) ; iostream operators + + "A regexp of fill points that should be filled *before*, not after. +By default, fillcode fills *after* fill points. When it fills at a fill point +that matches this regexp, it will fill *before* the fill point instead. + +Each regexp match must include one character *after* the fill point ends. +See `fillcode-fill-points' for more." + :type '(repeat string) + :group 'fillcode) + +(defcustom fillcode-start-token-re + (build-re + '("([^)]" "<<.")) ; "=\n" "{[^}]" "<[^>]" "\\[^]]") + "A list of strings to start filling at. +When fillcode is invoked, it first finds the beginning of the statement, then +looks for one of these strings. It will not fill anywhere before these strings. +This allows it to leave prefix clauses, like template declarations, intact. + +Each regexp match must include one character *after* the fill point ends." + :type '(repeat string) + :group 'fillcode) + +(defun fillcode-fill-paragraph (arg &optional arg2 arg3 arg4) + "Fill code at point if `fillcode-wrapped-fill-function' is nil. + +If `fillcode-wrapped-fill-function' is nil, fills code. If it's +non-nil, runs it first, and only fills code if it returns nil. + +Intended to be set as `fill-paragraph-function'." + ; first, consider calling the wrapped fill function + (let ((ret + (cond + ; if we're in cc-mode, this was called by the `c-fill-paragraph' + ; advice. so, don't call it again, it'd recurse infinitely. + ((eq fillcode-wrapped-fill-function 'c-fill-paragraph) + nil) + ; `python-fill-paragraph' in CVS Emacs' python.el always returns + ; t (grr!), so instead of looking at its return value, we fill if + ; the end of the line is not in a comment or string literal + ((and (eq major-mode 'python-mode) + (not (save-excursion (end-of-line) (fillcode-in-literal)))) + nil) + ; otherwise, if it's set, call the wrapped fill function + (fillcode-wrapped-fill-function + (funcall fillcode-wrapped-fill-function arg))))) + + + ; if the wrapped fill function did something, or we're possibly in a + ; multi-line literal, don't do anything more + (if (or ret (member (fillcode-in-literal) '(c c++ comment))) + ret + ; otherwise, normalize whitespace and fill + (save-excursion (save-restriction + (narrow-to-region (fillcode-beginning-of-statement) + (fillcode-end-of-statement)) + (goto-char (point-min)) + + (let ((inserted-brace + ; in cc-modes, insert an opening brace so that indentation (e.g. + ; for iostreams operators) works. sigh. + (if (member major-mode + '(c-mode c++-mode java-mode objc-mode perl-mode)) + (progn (insert " {\n") t))) ; else nil + (inserted-opener + ; if the first character is a closing char, temporarily replace + ; the whitespace before it with a matching open char so that the + ; major modes' indentation works. + (progn + (re-search-forward "\\S-" nil t) ; skip whitespace + (when (eq ?\) (fillcode-syntax (char-before))) + (let ((char (cdr (aref c-mode-syntax-table (char-before))))) + (goto-char (point-at-bol)) + (insert char "\n") + t))))) ; else nil + + ; if there's a start token, start at it + (let ((start + (if (re-search-forward fillcode-start-token-re nil t) + (match-beginning 0) + (point)))) + + ; normalize whitespace + (goto-char start) + (save-excursion + (condition-case nil (forward-char) (end-of-buffer nil)) + (fillcode-normalize-whitespace)) + + ; fill until we hit the end of the statement + (condition-case nil + (while (< (point) (point-max)) + (fillcode arg start) + (setq arg nil)) + (end-of-buffer t))) + + ; if we inserted characters, delete them. + (goto-char (point-min)) + (when inserted-brace + (delete-char 3)) + (when inserted-opener + (delete-char 2)) + + t)))))) + + +(defun fillcode (arg start) + "Fill code at point. +The actual function-call-filling algorithm. Fills function calls and prototypes +if it thinks the point is on a statement that has one. Uses start as a minimum +position bound; it won't fill before that position. + +Returns t if it actually filled somewhere (not including just normalizing +whitespace), nil otherwise." + (let ((filled nil)) + (catch 'sexp-end + ; if there's a prefix arg, fill at the first start token. + (when arg + (when (re-search-forward fillcode-start-token-re nil t) + (fillcode-fill-at-match) + (setq filled t))) + + ; the main loop. advances through the statement, filling as necessary. + ; recursive so we can easily determine, after we've finished with a + ; subexpression, whether we filled inside it. + (while (fillcode-forward) +;; (edebug) + ; skip literals + (while (fillcode-in-literal) + (forward-char)) + + ; fill if we need to + (when (fillcode-should-fill) + (fillcode-fill-at-fill-point 'backward start) + (setq filled t)) + + ; close-paren char, so it's the end of a sexp. return! + (when (and (eq ?\) (fillcode-syntax (char-after))) + ; don't return if it's a set of empty parens, or if there's + ; whitespace before the close paren char. in that case, it + ; might be an operator like >=, which is most definitely + ; *not* the end of a sexp. + (not (member (fillcode-syntax (char-before)) '(?\( ?\ )))) + (throw 'sexp-end t)) + + ; recurse into sexps + ; + ; TODO: HACK: BUG: this is dangerously broken. it recurses into empty + ; parens, but the clause above *doesn't* return from them. sooner or + ; later, this is going to cause problems. if i fix the clause above, + ; it tickles something and causes problems right now, and i haven't + ; yet figured out why. still, caveat user/hacker. + (when (eq ?\( (fillcode-syntax (char-after))) + ; if this sexp extends beyond fill-column, and there's an earlier + ; *non-open-paren* fill point we can use, fill at that fill point + (let ((next-fill-col (fillcode-fill-point-column-after-sexp))) + (when (and next-fill-col (> next-fill-col fill-column)) + (let ((prev-fill-pt (fillcode-find-fill-point-backward + (max start (point-at-bol))))) + (when (not (eq ?\( (fillcode-syntax (char-before prev-fill-pt)))) + (fillcode-fill-at-match))))) + + ; recurse! + (forward-char) + (if (fillcode nil start) + (fillcode-fill-at-fill-point 'forward))))) + + ; return t if we filled, nil otherwise + filled)) + +(defun fillcode-fill-at-fill-point (direction &optional bound) + "Fill at the nearest fill point. +Nearest fill point is found either before or after point, depending on +whether direction is 'backward or 'forward, respectively. Will not fill at a +fill point past bound (a position)." + (let ((find-fn (if (eq direction 'forward) + 'fillcode-find-fill-point-forward + 'fillcode-find-fill-point-backward))) + (when (funcall find-fn bound) + (fillcode-fill-at-match)))) + +(defun fillcode-fill-here () + "Fills right now, at point. +Inserts a newline and indents using `indent-according-to-mode'. + +If filling brings the new line to the same point as it was on the previous +line, doesn't fill, leaves point where it was before, and returns nil." + (let ((orig-col (current-column))) + (insert "\n") + (indent-according-to-mode) + (when (>= (current-column) orig-col) + ; no good, we're at the same column as before we filled. ok + ; then, just indent a little past the last line instead. + (indent-line-to (+ (fillcode-get-last-line-indent-offset) + (fillcode-get-mode-indent-offset)))) + (if (>= (current-column) orig-col) + ; no good, that didn't work either. ok, give up. :/ + (progn + (delete-indentation) + t) + nil))) + + +(defun fillcode-forward () + "Move forward to the next 'interesting' character. (Word-constituent +characters (letters, numbers, underscores, etc.) and whitespace are not +interesting.) Uses the current syntax table and `skip-syntax-forward'. + +If point is already on an interesting character, more forward just one +character. + +Return t if it moved point at all, nil otherwise." + (unless (eobp) + (if (eq (skip-syntax-forward "w_ >") 0) + (forward-char)) + t)) + +(defun fillcode-forward-sexp () + "Call forward-sexp and catch any errors. +Return t if it moved across an entire sexp, nil otherwise." + (unless (eobp) + (condition-case nil + (progn + (forward-sexp) + t) + (scan-error + (forward-char) + nil)))) + +(defun fillcode-beginning-of-statement () + "Return the start position of the statement that point is currently in. Uses +the major mode's beginning-of-statement function, if it has one. Otherwise, for +safety, just uses the beginning of the line." + (case major-mode + ((c-mode c++-mode java-mode objc-mode perl-mode) + ; if we're at the beginning of the statement, `c-beginning-of-statement' + ; will go to the *previous* statement. so, first move past a + ; non-whitespace character. + (beginning-of-line) + (re-search-forward "\\S-\\S-" nil t) ; whitespace + ; `c-beginning-of-statement-1' doesn't quite work. not sure why, haven't + ; investigated it yet. i should. + (c-beginning-of-statement 1) + ; NB: use point-at-bol for xemacs compatibility. the emacs function is + ; line-beginning-position; point-at-bol is just an alias. xemacs, however, + ; only has point-at-bol. (same with point-at-eol/line-end-position.) + (point-at-bol)) + + ((python-mode) + (save-excursion + (if (functionp 'py-goto-statement-at-or-above) + (py-goto-statement-at-or-above) + (python-beginning-of-statement)) + (point))) + + ; `c-beginning-of-statement' might be a good fallback for unknown + ; languages, but it occasionally fails badly, e.g. in `perl-mode'. + (otherwise + (point-at-bol)))) ; default + + +(defun fillcode-end-of-statement () + "Return the end position of the statement that point is currently in. +Uses the major mode's end-of-statement function, if it has one. Otherwise, +for safety, just uses the end of the line." + (save-excursion + (if (equal ?{ (char-before)) + (backward-char)) + + (case major-mode + ((c-mode c++-mode java-mode objc-mode perl-mode) + ; c-end-of-statement mostly does the right thing with if conditions, for + ; statements, {...} blocks, and statements that end with semicolon. + (c-end-of-statement)) + + ((python-mode) + (let ((start (point))) + (if (if (functionp 'py-goto-statement-below) + (py-goto-statement-below) + (python-next-statement)) + (search-backward ")" start 'p) + (condition-case nil (forward-char) (error nil)))))) + + ; `c-end-of-statement' might be a good fallback for unknown languages, + ; but it occasionally fails badly, e.g. in `perl-mode'. + (point-at-eol))) + + +(defun fillcode-normalize-whitespace () + "Normalize the current statement's whitespace, starting at point. +Specifically, no newlines, spaces before commas or open parens or after +close parens, one space after commas, one space before and after arithmetic +operators. Except string literals and comments, they're left untouched. + +Uses `fillcode-collapse-whitespace-forward'." + ; don't fill across blank lines, whether they're before point... + (save-excursion + (forward-line) + (beginning-of-line) + (if (re-search-backward "\n\\s-*\n" nil t) + (narrow-to-region (match-end 0) (point-max)))) + ; ...or after + (save-excursion + (forward-line -1) + (end-of-line) + (if (re-search-forward "\n\\s-*\n" nil t) + (narrow-to-region (point-min) (match-beginning 0)))) + + ; if we're in the indentation before the content of a line starts, preserve + ; the indentation. . use point-at-{b,e}ol for xemacs compatibility. + (if (not (save-excursion (re-search-backward "\\S-" (point-at-bol) t))) + (if (re-search-forward "\\S-" (point-at-eol) t) + (backward-char))) + (while (not (eobp)) + (fillcode-collapse-whitespace-forward))) + +(defun fillcode-collapse-whitespace-forward () + "Delete newlines, normalize whitespace, and/or move forward one character. +Specifically, no spaces before commas or open parens or after close parens, +one space after commas, one space before and after arithmetic operators. +Except string literals and comments, they're left untouched. Then advance +point to next non-whitespace char." +;; (edebug) + (let ((fill-point-re (build-re fillcode-fill-points))) + (cond + ; if we're in a string literal or comment, add a space before it, then skip + ; to the end of it + ((fillcode-in-literal) + (when (save-excursion (backward-char) (not (fillcode-in-literal))) + (fixup-whitespace) + (forward-char)) + ; TODO: maybe goto-char (cdr c-literal-limits) here would be faster? + (forward-char) + (if (equal "\n" (char-to-string (char-before))) + (indent-according-to-mode))) + + ; if we're at the end of the line, pull up the next line + ((eolp) + (delete-indentation t)) + + ; if we're on whitespace, delete it. if that brings us to a fill point, + ; fall down to the logic below. otherwise, normalize to exactly one space + ; and continue. + ((looking-at "\\s-") + (delete-horizontal-space) + (when (or (eq ?\( (fillcode-syntax (char-after))) + (not (looking-at fill-point-re))) + (fixup-whitespace) + (if (looking-at "\\s-") ; (*not* including newlines) + (forward-char)))) + + ; if we're before a non-special-punctuation fill point, add a space + ((and (looking-at fill-point-re) + (not (looking-at "[,;([{]\\|&[^&]\\||[^| ]"))) + (insert " ") + (goto-char (match-end 0))) + + ; if we're after a fill point, insert a space. (note that the fill point + ; regexp ends at the first char *after* the operator.) + ((and (save-excursion + (progn + (condition-case nil (forward-char) (error nil)) + ; use point-at-bol for xemacs compatibility + (re-search-backward fill-point-re (point-at-bol) t))) + (equal (point) (1- (match-end 0))) + (not (save-excursion (backward-char) (fillcode-in-literal)))) + (fixup-whitespace) + ; skip *past* the char we were on originally. if we inserted a + ; space, that's two chars forward, otherwise just one. + (forward-char (if (looking-at " ") 2 1))) + + ; ...otherwise, base case: advance one char + (t (forward-char))))) + + +(defun fillcode-should-fill () + "Return t if we should fill at the last fill point, nil otherwise. + +We should fill if: + +- there's a fill point on this line, AND +- we're not in a comment or string literal, AND +- the current char is at or beyond `fill-column'" + (and + (not (fillcode-in-literal)) ; not in a literal? + (>= (current-column) fill-column) ; past fill-column? + (save-excursion + (fillcode-find-fill-point-backward)))) ; fill point on this line? + + +(defun fillcode-find-fill-point-forward (&optional bound) + ; use point-at-eol for xemacs compatibility + (fillcode-find-fill-point-helper 're-search-forward + (if bound + (min bound (point-at-eol)) + (point-at-eol)))) + +(defun fillcode-find-fill-point-backward (&optional bound) + ; the fill point regexp ends at the first char *after* the + ; operator...so, move forward one char before searching. + (forward-char) + ; use point-at-bol for xemacs compatibility + (fillcode-find-fill-point-helper 're-search-backward + (if bound + (max bound (point-at-bol)) + (point-at-bol)))) + +(defun fillcode-fill-point-column-after-sexp () + "Return the column of the closest fill point after the sexp at point. +If there's no full sexp after point, returns nil." + (save-excursion + (if (fillcode-forward-sexp) + (let ((fill-pt (fillcode-find-fill-point-forward))) + (goto-char (if fill-pt fill-pt (point-at-eol))) + (current-column)) + nil))) + +(defun fillcode-find-fill-point-helper (re-search-fn bound) + "If there's a valid fill point on the current line, returns its position. + +Fill points are defined by `fillcode-fill-points'; commas, open parens, +arithmetic operators, ||s, &&s, etc. This function finds the closest one either +before or after point, depending on `forward'. + +It searches for fill points in the order that their regexps are specified in +`fillcode-fill-points'. + +If no fill point is found, returns nil." + (catch 'found + (dolist (re fillcode-fill-points) + (save-excursion + (while (funcall re-search-fn re bound t) + (save-match-data + (when (save-match-data (string-match fillcode-before-fill-point-re + (match-string 0))) + (goto-char (match-beginning 0))) + (when (not (or + ; can't fill if we're in a literal + (fillcode-in-literal) + ; ...or if we're at the beginning of the line + (save-excursion (skip-chars-backward " \t") + (eq (point) (point-at-bol))))) + ; found a fill point! + (throw 'found (point))))))) + + ; no fill point :( + nil)) + +(defun fillcode-fill-at-match () + "Fill at the fill point currently stored in the match data. + +This function expects a fill point to be stored in the match data. It should +usually be called after one of the `fillcode-find-fill-point-*' functions. It +leaves point at the first non-whitespace character on the new line." + (save-excursion + (goto-char + (if (save-match-data + (string-match fillcode-before-fill-point-re (match-string 0))) + (match-beginning 0) + (1- (match-end 0)))) + + (skip-chars-backward " \t") ; don't leave trailing whitespace + (fillcode-fill-here))) + + +(defun fillcode-in-literal () + "Return non-nil if inside a comment or string literal, nil otherwise. +Determines whether point is inside a comment, string literal, or other segment +that shouldn't be normalized or filled. Piggybacks on the major modes, since +it will usually have its code for this. + +Unfortunately, the major modes' in-literal functions (e.g. `c-in-literal' do +*not* consider literals' start tokens (\", ', /*, //, #) to be part of the +literal, so they return nil if point is on the start token. We want them to +return non-nil if we're past the first char of the start token, so +`fillcode-in-literal' returns non-nil instead." + (let ((in-literal-fn + (case major-mode + ((python-mode) (if (functionp 'py-in-literal) + 'py-in-literal 'python-in-string/comment)) + (otherwise 'c-in-literal)))) + + ; if the major mode says point *or* the char *after* point is in a literal, + ; or if two chars after point is a comment, then we're in a literal. + (or (funcall in-literal-fn) + (condition-case nil + (save-excursion + (forward-char) + (or (funcall in-literal-fn) + (progn + (forward-char) + (member (funcall in-literal-fn) '(c c++))))) + (error nil))))) + +(defun fillcode-get-mode-indent-offset () + "Returns the indent offset, ie the number of columns to indent, in the +current mode." + (case major-mode + ((python-mode) py-indent-offset) + (otherwise c-basic-offset))) + +(defun fillcode-get-last-line-indent-offset () + "Returns the indent offset, ie the column of the first non-whitespace +character, of the current line." + (save-excursion + (forward-line -1) + (beginning-of-line) + (skip-chars-forward " \t") ; skip whitespace + (current-column))) + +(defun fillcode-syntax (char) + "Returns the argument's syntax class, or nil if the argument is nil." + (if char + (char-syntax char))) + +(provide 'fillcode) + +;;; fillcode.el ends here Modified: configs/trunk/src/emacs/yang.el =================================================================== --- configs/trunk/src/emacs/yang.el 2009-05-07 07:19:37 UTC (rev 1394) +++ configs/trunk/src/emacs/yang.el 2009-05-07 07:43:33 UTC (rev 1395) @@ -99,6 +99,14 @@ ;; sunrise-commander (require 'sunrise-commander) +;; fillcode +(require 'fillcode) +(add-hook 'c-mode-common-hook 'fillcode-mode) +(add-hook 'perl-mode-hook 'fillcode-mode) +(add-hook 'python-mode-hook 'fillcode-mode) +(add-hook 'shell-script-mode-hook 'fillcode-mode) +(add-hook 'sql-mode-hook 'fillcode-mode) + ;; graphviz-mode (load "graphviz-dot-mode.el") @@ -442,16 +450,25 @@ ;; The variable scroll-margin restricts how close point can come to the top or bottom of a window. ;(setq scroll-margin 10) +;; TODO: determine if we need the following or if allout-mode is sufficient +;; properly fill bulleted lists +;; TODO: use a better setting for this. +;; (setq-default paragraph-start "\\ *-\\|$" +;; paragraph-separator "$") + ;; expand tabs into spaces (setq-default indent-tabs-mode nil) -(setq-default fill-column 80) +;; fill-column 80 ;; auto fill (setq-default auto-fill-function 'do-auto-fill) ;; tab, indent dimensions -(setq-default c-basic-offset 4) -(setq-default tab-width 4) +(setq-default c-basic-offset 2) +(setq-default python-indent 2) +(setq-default sh-basic-offset 2) +(setq-default sh-indentation 2) +(setq-default tab-width 2) ;; Make lines wrap automatically in text mode. ;;(add-hook 'text-mode-hook @@ -519,7 +536,7 @@ ;; Flyspell is an in-line spell checker. It checks the spelling as you type. (dolist (hook '(text-mode-hook)) -(add-hook hook (lambda () (refill-mode 1)))) +;; (add-hook hook (lambda () (refill-mode 1)))) (add-hook hook (lambda () (flyspell-mode 1)))) ;; }}} @@ -677,4 +694,6 @@ ;; use pretty fonts (if (>= emacs-major-version 23) - (set-default-font "Bitstream Vera Sans Mono-10")) + (set-default-font "Monospace-10")) +;; TODO this doesn't work +;; (set-default-font "Bitstream Vera Sans Mono-10")) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 07:19:38
|
Revision: 1394 http://assorted.svn.sourceforge.net/assorted/?rev=1394&view=rev Author: yangzhang Date: 2009-05-07 07:19:37 +0000 (Thu, 07 May 2009) Log Message: ----------- updated backup.bash to back up secret files as well Modified Paths: -------------- configs/trunk/src/cron/backup.bash Modified: configs/trunk/src/cron/backup.bash =================================================================== --- configs/trunk/src/cron/backup.bash 2009-05-07 07:18:28 UTC (rev 1393) +++ configs/trunk/src/cron/backup.bash 2009-05-07 07:19:37 UTC (rev 1394) @@ -28,3 +28,8 @@ run-duplicity ~/.quodlibet/ quodlibet run-duplicity ~/.gnupg/ gpg run-duplicity ~/.supybot/ supybot + +mkdir -p ~/.backup-secret/ +cp ~/.{backup.auth,gbookmark2delicious.auth,google.auth,googlecode.auth,lastfmkey,mlf.auth,y_z.cnf} \ + ~/.backup-secret/ +run-duplicity ~/.backup-secret/ backup-secret This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 07:18:35
|
Revision: 1393 http://assorted.svn.sourceforge.net/assorted/?rev=1393&view=rev Author: yangzhang Date: 2009-05-07 07:18:28 +0000 (Thu, 07 May 2009) Log Message: ----------- logging changes, added todo, added requirements, updated descrip Modified Paths: -------------- music-labeler/trunk/README Modified: music-labeler/trunk/README =================================================================== --- music-labeler/trunk/README 2009-05-07 07:16:07 UTC (rev 1392) +++ music-labeler/trunk/README 2009-05-07 07:18:28 UTC (rev 1393) @@ -1,8 +1,9 @@ Overview -------- -Label your music using a tagging interface not unlike those of online bookmark -managers. +Label your music using a tagging interface not unlike those of the pop-up +bookmarklets of such online bookmark managers as Google Bookmarks. Currently +works with the [Quod Libet] music manager. Setup ----- @@ -11,21 +12,42 @@ - [pygtk] 2.13 - [GST] 0.10 -- [Quodlibet] 1.0 +- [pylast] 0.2.18 +- [Quod Libet] 1.0 [pygtk]: http://www.pygtk.org/ [GST]: http://gstreamer.freedesktop.org/modules/gst-python.html -[Quodlibet]: http://code.google.com/p/quodlibet/ +[pylast]: http://code.google.com/p/pylast/ +[Quod Libet]: http://code.google.com/p/quodlibet/ Related ------- -Another application that demonstrates GTK autocompletion is [drun] +Another application that demonstrates GTK autocompletion is [drun]; this was +instructional to refer to. [drun]: http://sourceforge.net/projects/drun/ +Changes +------- + +version 0.1 (upcoming) + +- initial release +- drop-down auto-completion labeling for Quod Libet +- music playback and control + Todo ---- -- Integrate into quodlibet. -- Move to quodlibet 2.0. +Bugs + +- Scroll to the Entry with focus. +- Adjust the pop-up appropriately when resizing. + +Enhancements + +- Match Google Bookmarks keys. +- Make prettier UI (look into using a big tabular TreeView instead of Labels). +- Move to Quod Libet 2.0. +- Integrate into Quod Libet. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 07:16:08
|
Revision: 1392 http://assorted.svn.sourceforge.net/assorted/?rev=1392&view=rev Author: yangzhang Date: 2009-05-07 07:16:07 +0000 (Thu, 07 May 2009) Log Message: ----------- - added pylast api support to show top tags on last.fm - added thread-safe callbacks to enable asynchronous calls from helper threads into the blocking pylast api - fixed show_popup to be connected to configure-event - fixed dir of skipping forward/backward in the music - fixed scrolling Modified Paths: -------------- music-labeler/trunk/src/ml.py Modified: music-labeler/trunk/src/ml.py =================================================================== --- music-labeler/trunk/src/ml.py 2009-05-07 07:16:03 UTC (rev 1391) +++ music-labeler/trunk/src/ml.py 2009-05-07 07:16:07 UTC (rev 1392) @@ -2,18 +2,17 @@ from __future__ import with_statement from gtk import * -from cgi import escape from cStringIO import StringIO -import itertools, gst, urllib +import itertools, gst, urllib, cgi, collections, pylast, contextlib import gtk.keysyms as k, gtk.gdk as gdk -from os.path import expanduser from path import path -from collections import defaultdict +# Last.FM administrivia +lastfm_apikey = '3222517b613ce7a7091f1aff29edd67a' + # Quod Libet messiness. sys.path.append('/usr/share/quodlibet/') -import util -import formats +import util, formats util.gettext_install() from browsers.playlists import Playlist quote, unquote = Playlist.quote, Playlist.unquote @@ -24,7 +23,7 @@ def debug(*args): if do_debug: print ' '.join(map(str,args)) -cap = 50 +cap = 30 def trunc(s): s = str(s) return s[:cap] + '...' if len(s) > cap else s @@ -33,6 +32,12 @@ # GTK+ helpers. +...@co...ntextmanager +def gdksync(): + gdk.threads_enter() + try: yield + finally: gdk.threads_leave() + def connecting(widget, signal): def wrapper(handler): widget.connect(signal, handler) @@ -48,6 +53,8 @@ # Main GUI layer. def labeler(pls, labels, track_paths): + gdk.threads_init() + sep = ';' player = gst.element_factory_make('playbin') @@ -74,7 +81,20 @@ def make_e(track_path): meta = formats.MusicFile(track_path) + def clean(s): return trunc(cgi.escape(s)) + caption = '%s - %s' % (clean(meta.get('artist', '[Unknown Artist]')), + clean(meta.get('title', '[Untitled]'))) + disp = Label(caption) + try: artist = pylast.Artist(meta['artist'], lastfm_apikey, '', '') + except KeyError: pass + else: + def cb(artist, tags): + with gdksync(): + tagstr = cgi.escape(', '.join([tag.getName() for tag in tags][:5])) + disp.set_markup(disp.get_text() + ' <i>(%s)</i>' % tagstr) + artist.async_call(artist.getTopTags, cb) + def refresh(): 'Called when the list is changed.' labels.sort(key = str.lower) @@ -138,12 +158,12 @@ else: i += 1 pieces += [m[lasti:]] - m = ''.join(('<b>' + escape(p[0]) + '</b>' + m = ''.join(('<b>' + cgi.escape(p[0]) + '</b>' if type(p) == tuple - else escape(p)) + else cgi.escape(p)) for p in pieces) else: - m = escape(m) + m = cgi.escape(m) l.append([m]) # Something is always selected in the list. t.get_selection().select_path(0) @@ -189,6 +209,8 @@ if itr is not None: (pos,) = l.get_path(itr) pos += dir + if pos == -1: pos = len(l) - 1 + if pos == len(l): pos = 0 else: pos = 0 if ev.keyval == k.Down else len(l) - 1 if 0 <= pos < len(l): @@ -205,7 +227,7 @@ ev.state & gdk.CONTROL_MASK: # Seek forward/backward 5 seconds. pos = player.query_position(timefmt)[0] - dir = 1 if ev.keyval == k.comma else 1 + dir = -1 if ev.keyval == k.comma else 1 debug('seek from', pos / 1e9, 'to', pos + dir * 5e9) player.seek_simple(timefmt, gst.SEEK_FLAG_FLUSH, pos + dir * 5e9) return True @@ -250,6 +272,7 @@ refresh() @connecting_after(e, 'focus-in-event') # TODO hack; too early on resizes + @connecting_after(e, 'configure-event') def show_popup(*args): # Play the track if not already playing. uri = 'file://' + urllib.quote(track_path) @@ -274,9 +297,7 @@ tw.move(ex+ew,ey) row = rows.next() - caption = '%s - %s' % (trunc(meta.get('artist', '[Unknown Artist]')), - trunc(meta.get('title', '[Untitled]'))) - tab.attach(Label(str = caption), 0, 1, row, row+1) + tab.attach(disp, 0, 1, row, row+1) tab.attach(e, 1, 2, row, row+1) es.append(e) return e @@ -295,7 +316,7 @@ main() # Update playlists in memory. - newpls = defaultdict(set) + newpls = collections.defaultdict(set) for track_path, e in path2e.iteritems(): # Remove from all playlists. for pl in pls.itervalues(): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 07:16:05
|
Revision: 1391 http://assorted.svn.sourceforge.net/assorted/?rev=1391&view=rev Author: yangzhang Date: 2009-05-07 07:16:03 +0000 (Thu, 07 May 2009) Log Message: ----------- program not yet released Modified Paths: -------------- music-labeler/trunk/publish.bash Modified: music-labeler/trunk/publish.bash =================================================================== --- music-labeler/trunk/publish.bash 2009-05-07 07:07:03 UTC (rev 1390) +++ music-labeler/trunk/publish.bash 2009-05-07 07:16:03 UTC (rev 1391) @@ -8,4 +8,5 @@ license=gpl3 websrcs=( README ) rels=( pypi: ) +nodl=true . assorted.bash "$@" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 07:07:09
|
Revision: 1390 http://assorted.svn.sourceforge.net/assorted/?rev=1390&view=rev Author: yangzhang Date: 2009-05-07 07:07:03 +0000 (Thu, 07 May 2009) Log Message: ----------- added quodlibet-rmdups Added Paths: ----------- sandbox/trunk/src/one-off-scripts/quodlibet-rmdups.py Added: sandbox/trunk/src/one-off-scripts/quodlibet-rmdups.py =================================================================== --- sandbox/trunk/src/one-off-scripts/quodlibet-rmdups.py (rev 0) +++ sandbox/trunk/src/one-off-scripts/quodlibet-rmdups.py 2009-05-07 07:07:03 UTC (rev 1390) @@ -0,0 +1,53 @@ +#!/usr/bin/env python + +from __future__ import with_statement +from path import path +import collections, itertools, sys + +# Quod Libet messiness. +sys.path.append('/usr/share/quodlibet/') +import util, formats +util.gettext_install() +from browsers.playlists import Playlist +quote, unquote = Playlist.quote, Playlist.unquote + +base = path('/home/yang/shared/archive/managed music') +new = base / 'new' +def getmatches(): + for query in new.files(): + sz, md5 = query.size, query.read_md5() + matches = [ f for f in base.walk() + if f.parent != new and f.size == sz] #and f.read_md5() == md5 ] + meta = formats.MusicFile(query) + trackno = '%02d' % int(meta['tracknumber'].split('/')[0]) + renamed = (base / meta['performer'] / meta['album'] / trackno + + ' - ' + meta['title'] + query.ext) + if renamed.isfile(): matches.append(renamed) + yield query, matches + +def read(p): + with file(p) as f: + return map(str.rstrip, f.readlines()) + +fst = lambda (a,b): a +snd = lambda (a,b): b + +def mmap(pairs): + d = dict( (a, set(map(snd, ps))) + for (a, ps) in itertools.groupby(sorted(pairs), fst) ) + dd = collections.defaultdict(lambda: set()) + dd.update(d) + return dd + +pls = [(pl.name, read(pl)) for pl in path('/home/yang/.quodlibet/playlists').files()] +f2p = mmap((f, p) for (p, fs) in pls for f in fs) +tags = lambda q: '; '.join(f2p[q]) +show = lambda q: '%s (%s): %s' % (q.replace(base / '', ''), q.size, tags(q)) + +for q, ms in getmatches(): + md5 = q.read_md5() + print show(q) + if len(ms) > 0: + for m in ms: + print '>' if md5 == m.read_md5() else '-', show(m) + print Property changes on: sandbox/trunk/src/one-off-scripts/quodlibet-rmdups.py ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 06:57:37
|
Revision: 1389 http://assorted.svn.sourceforge.net/assorted/?rev=1389&view=rev Author: yangzhang Date: 2009-05-07 06:57:35 +0000 (Thu, 07 May 2009) Log Message: ----------- oops, committed api key Modified Paths: -------------- sandbox/trunk/src/py/lastfm.py Modified: sandbox/trunk/src/py/lastfm.py =================================================================== --- sandbox/trunk/src/py/lastfm.py 2009-05-07 06:25:44 UTC (rev 1388) +++ sandbox/trunk/src/py/lastfm.py 2009-05-07 06:57:35 UTC (rev 1389) @@ -2,8 +2,9 @@ # Demo of using pylast, the last.fm Python API. -import pylast -api = '3222517b613ce7a7091f1aff29edd67a' +from __future__ import with_statement +import pylast, os +with file(os.path.expanduser('~/.lastfmkey')) as f: api = f.read().strip() a = pylast.Artist('daughtry', api) def cb(*args): print args a.async_call(call = a.getTopTags, callback = cb) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 06:25:45
|
Revision: 1388 http://assorted.svn.sourceforge.net/assorted/?rev=1388&view=rev Author: yangzhang Date: 2009-05-07 06:25:44 +0000 (Thu, 07 May 2009) Log Message: ----------- added pylast demo Added Paths: ----------- sandbox/trunk/src/py/lastfm.py Added: sandbox/trunk/src/py/lastfm.py =================================================================== --- sandbox/trunk/src/py/lastfm.py (rev 0) +++ sandbox/trunk/src/py/lastfm.py 2009-05-07 06:25:44 UTC (rev 1388) @@ -0,0 +1,9 @@ +#!/usr/bin/env python + +# Demo of using pylast, the last.fm Python API. + +import pylast +api = '3222517b613ce7a7091f1aff29edd67a' +a = pylast.Artist('daughtry', api) +def cb(*args): print args +a.async_call(call = a.getTopTags, callback = cb) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 06:16:58
|
Revision: 1387 http://assorted.svn.sourceforge.net/assorted/?rev=1387&view=rev Author: yangzhang Date: 2009-05-07 06:16:56 +0000 (Thu, 07 May 2009) Log Message: ----------- added jquery Added Paths: ----------- sandbox/trunk/src/jquery/ sandbox/trunk/src/jquery/autocomplete.html Added: sandbox/trunk/src/jquery/autocomplete.html =================================================================== --- sandbox/trunk/src/jquery/autocomplete.html (rev 0) +++ sandbox/trunk/src/jquery/autocomplete.html 2009-05-07 06:16:56 UTC (rev 1387) @@ -0,0 +1,21 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" + "http://www.w3.org/TR/html4/loose.dtd"> +<html> +<head> + <script src="http://code.jquery.com/jquery-latest.js"></script> + <link rel="stylesheet" href="http://dev.jquery.com/view/trunk/plugins/autocomplete/demo/main.css" type="text/css" /> + <link rel="stylesheet" href="http://dev.jquery.com/view/plugins/autocomplete/1.0.2/jquery.autocomplete.css" type="text/css" /> + <script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.bgiframe.min.js"></script> + <script type="text/javascript" src="http://dev.jquery.com/view/plugins/autocomplete/1.0.2/jquery.autocomplete.js"></script> + <script> + $(document).ready(function(){ + var data = "Core Selectors Attributes Traversing Manipulation CSS Events Effects Ajax Utilities".split(" "); +$("#example").autocomplete(data); + }); + </script> + +</head> +<body> + API Reference: <input id="example" /> (try "C" or "E") +</body> +</html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 06:13:05
|
Revision: 1386 http://assorted.svn.sourceforge.net/assorted/?rev=1386&view=rev Author: yangzhang Date: 2009-05-07 06:13:04 +0000 (Thu, 07 May 2009) Log Message: ----------- added perftools demo Added Paths: ----------- sandbox/trunk/src/misc/perftools/ sandbox/trunk/src/misc/perftools/Makefile sandbox/trunk/src/misc/perftools/README sandbox/trunk/src/misc/perftools/main.c sandbox/trunk/src/misc/perftools/st.c Added: sandbox/trunk/src/misc/perftools/Makefile =================================================================== --- sandbox/trunk/src/misc/perftools/Makefile (rev 0) +++ sandbox/trunk/src/misc/perftools/Makefile 2009-05-07 06:13:04 UTC (rev 1386) @@ -0,0 +1,6 @@ +TARGETS = main st +LDLIBS += -lprofiler -lst +all: $(TARGETS) +.PHONY: clean +clean: + rm -f $(TARGETS) Added: sandbox/trunk/src/misc/perftools/README =================================================================== --- sandbox/trunk/src/misc/perftools/README (rev 0) +++ sandbox/trunk/src/misc/perftools/README 2009-05-07 06:13:04 UTC (rev 1386) @@ -0,0 +1,3 @@ +Demo of how google perftools CPU profiler can only profile CPU time not time +spent blocking (sleeping in this case). Demo of both regular sleep, a bunch of +usleeps, and st sleeps. Added: sandbox/trunk/src/misc/perftools/main.c =================================================================== --- sandbox/trunk/src/misc/perftools/main.c (rev 0) +++ sandbox/trunk/src/misc/perftools/main.c 2009-05-07 06:13:04 UTC (rev 1386) @@ -0,0 +1,12 @@ +#include <unistd.h> +int main() { + int i; +#if 0 + for (i = 0; i < 100000; ++i) { + usleep(1); + } +#else + sleep(1); +#endif + return 0; +} Added: sandbox/trunk/src/misc/perftools/st.c =================================================================== --- sandbox/trunk/src/misc/perftools/st.c (rev 0) +++ sandbox/trunk/src/misc/perftools/st.c 2009-05-07 06:13:04 UTC (rev 1386) @@ -0,0 +1,7 @@ +#include <st.h> +int main() { + st_init(); + st_sleep(1); + st_sleep(1); + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 06:10:34
|
Revision: 1385 http://assorted.svn.sourceforge.net/assorted/?rev=1385&view=rev Author: yangzhang Date: 2009-05-07 06:10:33 +0000 (Thu, 07 May 2009) Log Message: ----------- added pty demo Added Paths: ----------- sandbox/trunk/src/nix/pty/ sandbox/trunk/src/nix/pty/master.py Added: sandbox/trunk/src/nix/pty/master.py =================================================================== --- sandbox/trunk/src/nix/pty/master.py (rev 0) +++ sandbox/trunk/src/nix/pty/master.py 2009-05-07 06:10:33 UTC (rev 1385) @@ -0,0 +1,12 @@ +#!/usr/bin/env python + +# Demo that a forked process can read the same stdin + +import os, pty, time + +pid, fd = pty.fork() +if pid == 0: # Child + print 'Child with fd =', fd +else: + print 'Master with fd =', fd + print 'Read:', os.read(fd, 4096) Property changes on: sandbox/trunk/src/nix/pty/master.py ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 06:09:48
|
Revision: 1384 http://assorted.svn.sourceforge.net/assorted/?rev=1384&view=rev Author: yangzhang Date: 2009-05-07 06:09:36 +0000 (Thu, 07 May 2009) Log Message: ----------- added c++0x macro demo Added Paths: ----------- sandbox/trunk/src/gcc/macro_0x.cc Added: sandbox/trunk/src/gcc/macro_0x.cc =================================================================== --- sandbox/trunk/src/gcc/macro_0x.cc (rev 0) +++ sandbox/trunk/src/gcc/macro_0x.cc 2009-05-07 06:09:36 UTC (rev 1384) @@ -0,0 +1,5 @@ +// This is a file that you can compile with g++ -std=c++0x but not with regular +// g++. The way to detect whether you're in C++0x mode is to check this macro. +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +int main() { return 0; } +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 06:07:27
|
Revision: 1383 http://assorted.svn.sourceforge.net/assorted/?rev=1383&view=rev Author: yangzhang Date: 2009-05-07 06:07:23 +0000 (Thu, 07 May 2009) Log Message: ----------- added a bunch more tests Modified Paths: -------------- sandbox/trunk/src/cc/boost_function.cc sandbox/trunk/src/cc/fast_map/Makefile sandbox/trunk/src/cc/fast_map/main.cc sandbox/trunk/src/cc/htons_conversion.cc sandbox/trunk/src/cc/rvaluerefs.cc sandbox/trunk/src/cc/smartptrs.cc Added Paths: ----------- sandbox/trunk/src/cc/acpp.cc sandbox/trunk/src/cc/acpp.mk sandbox/trunk/src/cc/address_of_template_instance.cc sandbox/trunk/src/cc/algo.cc sandbox/trunk/src/cc/alignof.cc sandbox/trunk/src/cc/assert.cc sandbox/trunk/src/cc/auto_ptr.cc sandbox/trunk/src/cc/boost_iterators.cc sandbox/trunk/src/cc/castalign.cc sandbox/trunk/src/cc/fast_map/fm4.h sandbox/trunk/src/cc/inline2.cc sandbox/trunk/src/cc/iomanip.cc sandbox/trunk/src/cc/map.cc sandbox/trunk/src/cc/moves.cc sandbox/trunk/src/cc/nonvirt_dtor.cc sandbox/trunk/src/cc/randperf.cc sandbox/trunk/src/cc/streambufs.cc.cog sandbox/trunk/src/cc/unordered_map.cc Added: sandbox/trunk/src/cc/acpp.cc =================================================================== --- sandbox/trunk/src/cc/acpp.cc (rev 0) +++ sandbox/trunk/src/cc/acpp.cc 2009-05-07 06:07:23 UTC (rev 1383) @@ -0,0 +1,18 @@ +#include <iostream> +using namespace std; +aspect Trace { + pointcut functions() = "% main(...)"; + advice execution(functions()) : around() { + cout << "before " << JoinPoint::signature() << endl; + tjp->proceed(); + cout << "after" << endl; + } +}; +aspect PosixExceptions { + advice call("") : after() { + tjp->result(); + } +}; +int main() { + return 0; +} Added: sandbox/trunk/src/cc/acpp.mk =================================================================== --- sandbox/trunk/src/cc/acpp.mk (rev 0) +++ sandbox/trunk/src/cc/acpp.mk 2009-05-07 06:07:23 UTC (rev 1383) @@ -0,0 +1,2 @@ +CXX = ag++ -k +all: acpp Added: sandbox/trunk/src/cc/address_of_template_instance.cc =================================================================== --- sandbox/trunk/src/cc/address_of_template_instance.cc (rev 0) +++ sandbox/trunk/src/cc/address_of_template_instance.cc 2009-05-07 06:07:23 UTC (rev 1383) @@ -0,0 +1,19 @@ +// Demo of how to get the address of a template instantiation, i.e. work around +// GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29187>. + +#include <iostream> +using namespace std; + +template<typename T> void f(T &t) { ++t; } + +int main() { + void (*ptr)(int&) = &f<int>; + int x = 0; + ptr(x); + // error: assuming cast to type 'bool (*)(evaluator&)' from + // overloaded function + // bool b = ptr == &f<int>; + bool b = ptr == (void(*)(int&))(&f<int>); + cout << b << endl; + return 0; +} Added: sandbox/trunk/src/cc/algo.cc =================================================================== --- sandbox/trunk/src/cc/algo.cc (rev 0) +++ sandbox/trunk/src/cc/algo.cc 2009-05-07 06:07:23 UTC (rev 1383) @@ -0,0 +1,22 @@ +#include <algorithm> +#include <iostream> +#include <string> +using namespace std; +int main() { + // copy can only overwrite. + string s("hello"), t("seeya world"); + copy(s.begin(), s.end(), t.begin()); + cout << t << endl; + + // d remains empty here. + string d; + copy(s.begin(), s.end(), d.begin()); + cout << d << endl; + + // swap + int a=0, b=1; + swap(a, b); + cout << a << ' ' << b << endl; + + return 0; +} Added: sandbox/trunk/src/cc/alignof.cc =================================================================== --- sandbox/trunk/src/cc/alignof.cc (rev 0) +++ sandbox/trunk/src/cc/alignof.cc 2009-05-07 06:07:23 UTC (rev 1383) @@ -0,0 +1,7 @@ +#include <iostream> +using namespace std; +int main() { + cout << __alignof__(int) << endl + << __alignof__(char) << endl; + return 0; +} Added: sandbox/trunk/src/cc/assert.cc =================================================================== --- sandbox/trunk/src/cc/assert.cc (rev 0) +++ sandbox/trunk/src/cc/assert.cc 2009-05-07 06:07:23 UTC (rev 1383) @@ -0,0 +1,8 @@ +// Demo of how to disable assert() +#define NDEBUG // disables assert() +#include <cassert> +using namespace std; +int main() { + assert(false); + return 0; +} Added: sandbox/trunk/src/cc/auto_ptr.cc =================================================================== --- sandbox/trunk/src/cc/auto_ptr.cc (rev 0) +++ sandbox/trunk/src/cc/auto_ptr.cc 2009-05-07 06:07:23 UTC (rev 1383) @@ -0,0 +1,20 @@ +#include <memory> +#include <vector> +using namespace std; + +auto_ptr<int> source() { return auto_ptr<int>(new int); } +void sink(auto_ptr<int>) {} + +int main() { + auto_ptr<int> p(new int); + auto_ptr<int> q(p); + + sink(source()); + + vector<auto_ptr<int> > xs; + // This is not allowed. + // xs.push_back(auto_ptr<int>(new int)); + // xs.push_back(q); + + return 0; +} Modified: sandbox/trunk/src/cc/boost_function.cc =================================================================== --- sandbox/trunk/src/cc/boost_function.cc 2009-05-07 05:42:39 UTC (rev 1382) +++ sandbox/trunk/src/cc/boost_function.cc 2009-05-07 06:07:23 UTC (rev 1383) @@ -5,6 +5,9 @@ using namespace std; void show(int x) { cout << x << endl; } void twice(function0<void> f) { f(); f(); } +struct adder { + int operator()(int x, int y) { return x + y; } +}; int main() { // This works... function<void()> f = bind(show, 0); @@ -24,5 +27,15 @@ function<void(int)> h = g; h(0); } + + { + // Can't use nested classes. + // struct adder { + // int operator()(int x, int y) { return x + y; } + // }; + function<int(int, int)> add = adder(); + cout << add(2, 3) << endl; + } + return 0; } Added: sandbox/trunk/src/cc/boost_iterators.cc =================================================================== --- sandbox/trunk/src/cc/boost_iterators.cc (rev 0) +++ sandbox/trunk/src/cc/boost_iterators.cc 2009-05-07 06:07:23 UTC (rev 1383) @@ -0,0 +1,26 @@ +// Demos how to use iterator_range. + +#include <boost/foreach.hpp> +#include <boost/range/iterator_range.hpp> +#include <iostream> +#include <map> +#define foreach BOOST_FOREACH + +using namespace boost; +using namespace std; + +int main() { + typedef map<int, int> mii; + map<int, int> map; + for (int i = 0; i < 10; i++) { + map[i] = -i; + } + // The following will be a build error because `map` will refer to the value, not the type. + // map<int, int>::iterator begin = map.lower_bound(5); + mii::iterator begin = map.lower_bound(5), end = map.lower_bound(8); + typedef pair<int, int> pii; + foreach (pii p, make_iterator_range(begin, end)) { + cout << p.first << " " << p.second << endl; + } + return 0; +} Added: sandbox/trunk/src/cc/castalign.cc =================================================================== --- sandbox/trunk/src/cc/castalign.cc (rev 0) +++ sandbox/trunk/src/cc/castalign.cc 2009-05-07 06:07:23 UTC (rev 1383) @@ -0,0 +1,36 @@ +// TODO: understand alignment behavior. +// +// This program requires c++0x for alignment_of. +// +// Result: at least on x86 you can read/write ints aligned at any location, +// regardless of the native (preferred) alignment, but the code may run slower +// as a result. +// +// See <http://gcc.gnu.org/ml/gcc-help/2009-02/msg00096.html>: +// +// > The x86 supports misaligned accesses for basic types. The instructions do +// > what you expect, though in some cases they will take a few more clock +// > cycles. + +#include <cstdio> +#include <cstring> +#include <iostream> +#include <type_traits> +using namespace std; + +enum { sz = 8 }; + +int main() { + cout << __alignof__(int) << endl; + cout << alignment_of<int>::value << endl; + + char a[sz]; + cout << (void*)a << endl; + bzero(a, sz); + + *((int*)(a+1)) = -1; + for (int i = 0; i < sz; ++i) printf("%02hhx ", a[i]); + cout << endl; + + return 0; +} Modified: sandbox/trunk/src/cc/fast_map/Makefile =================================================================== --- sandbox/trunk/src/cc/fast_map/Makefile 2009-05-07 05:42:39 UTC (rev 1382) +++ sandbox/trunk/src/cc/fast_map/Makefile 2009-05-07 06:07:23 UTC (rev 1383) @@ -1,6 +1,6 @@ CXXFLAGS = -Wall -Wextra -Wconversion -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Winit-self -Wno-unused-parameter -Wparentheses -Wmissing-format-attribute -Wfloat-equal -Woverloaded-virtual -Wsign-promo -Wc++0x-compat -Wsynth -Wall -Werror -Wextra -Wstrict-null-sentinel -Wold-style-cast -Woverloaded-virtual -Wsign-promo -Wformat=2 -Winit-self -Wswitch-enum -Wunused -Wfloat-equal -Wundef -Wunsafe-loop-optimizations -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wlogical-op -Wno-aggregate-return -Wno-missing-declarations -Wno-missing-field-initializers -Wmissing-format-attribute -Wpacked -Wredundant-decls -Winvalid-pch -Wlong-long -Wvolatile-register-var -O3 -DNDEBUG all: main -main: fm0.h fm1.h fm2.h fm3.h +main: fm0.h fm1.h fm2.h fm3.h fm4.h clean: rm -f main .PHONY: clean Copied: sandbox/trunk/src/cc/fast_map/fm4.h (from rev 1260, sandbox/trunk/src/cc/fast_map/fm3.h) =================================================================== --- sandbox/trunk/src/cc/fast_map/fm4.h (rev 0) +++ sandbox/trunk/src/cc/fast_map/fm4.h 2009-05-07 06:07:23 UTC (rev 1383) @@ -0,0 +1,124 @@ +#include <backward/hash_fun.h> +#include <cassert> +#include <commons/array.h> +#include <utility> + +using namespace std; +using namespace __gnu_cxx; + +class fast_map4 +{ + private: + static const size_t initsize = 1<<20; + typedef pair<int, int> entry; + commons::array<entry> table; + int empty_key, deleted_key; + size_t count; + hash<int> hasher; + void resize(size_t size) { + // NOTE: don't default-construct every element + commons::array<entry> tmp(0); + tmp.reset(reinterpret_cast<entry*>(new char[size * sizeof(entry)]), size); + for (size_t i = 0; i < size; ++i) + tmp[i].first = empty_key; + swap(table, tmp); + // Rehash old values over into new table. + size_t mask = table.size() - 1; + for (size_t i = 0; i < tmp.size(); ++i) { + if (tmp[i].first != empty_key && tmp[i].first != deleted_key) { + // NOTE: second major speedup, originally: + // (*this)[tmp[i].first] = tmp[i].second; + // Don't want to simply reuse the general lookup, since we know + // we're starting with a blank slate. + size_t pos = hasher(tmp[i].first) & mask; + for (size_t probe = 0; + table[pos].first != empty_key; + ++probe, pos = (pos + probe) & mask) { + assert(probe < table.size()); + } + table[pos] = tmp[pos]; + } + } + } + void grow() { resize(table.size() << 1); } + void shrink() { resize(table.size() >> 1); } + public: + fast_map4() : table(0), empty_key(0), deleted_key(0), count(0) {} + void set_empty_key(int k) { empty_key = k; resize(initsize); } + void set_deleted_key(int k) { deleted_key = k; resize(initsize); } + size_t size() const { return count; } + int &operator[](int k) { + size_t probe, mask = table.size() - 1, pos = hasher(k) & mask; + // Lookup. Skip over deleted entries (but remembering the first one + // seen as an open slot if we later decide to insert). If we find an + // empty spot, try returning the earlier deleted spot first. If we + // find the key, return that. + for (probe = 0; + table[pos].first != deleted_key && table[pos].first != empty_key && table[pos].first != k; + ++probe, pos = (pos + probe) & mask) { + assert(probe < table.size()); + } + if (table[pos].first == deleted_key) { + size_t first_deleted = pos; + for (; + table[pos].first != empty_key && table[pos].first != k; + ++probe, pos = (pos + probe) & mask) { + assert(probe < table.size()); + } + if (table[pos].first == empty_key) { + // Inserting new entry. Grow table if necessary. + if (++count > table.size() * 3 / 4) { + --count; + grow(); + return (*this)[k]; + } + pos = first_deleted; + table[pos].first = k; + } + } else if (table[pos].first == empty_key) { + // Inserting new entry. Grow table if necessary. + if (++count > table.size() * 3 / 4) { + --count; + grow(); + return (*this)[k]; + } + table[pos].first = k; + } + return table[pos].second; +#if 0 + size_t probe, mask = table.size() - 1, pos = hasher(k) & mask, unset = -1, first_deleted = unset; + // Lookup. Skip over deleted entries (but remembering the first one + // seen as an open slot if we later decide to insert). If we find an + // empty spot, try returning the earlier deleted spot first. If we + // find the key, return that. + for (probe = 0; ; ++probe) { + assert(probe < table.size()); + // NOTE: using & mask instead of % table.size() + pos = (pos + probe) & mask; + int &key = table[pos].first; + if (key == deleted_key && first_deleted == unset) { + first_deleted = pos; + } else if (key == empty_key) { + // Inserting new entry. Grow table if necessary. + ++count; + if (count > table.size() * 3 / 4) { + --count; + grow(); + return (*this)[k]; + } + + // Try using an earlier-encountered deleted spot, if any. + if (first_deleted != unset) pos = first_deleted; + + table[pos].first = k; + break; + } else if (key == k) { + break; + } + } + assert(probe < table.size()); + assert(table[pos].first == k); + return table[pos].second; +#endif + } +}; Property changes on: sandbox/trunk/src/cc/fast_map/fm4.h ___________________________________________________________________ Added: svn:mergeinfo + Modified: sandbox/trunk/src/cc/fast_map/main.cc =================================================================== --- sandbox/trunk/src/cc/fast_map/main.cc 2009-05-07 05:42:39 UTC (rev 1382) +++ sandbox/trunk/src/cc/fast_map/main.cc 2009-05-07 06:07:23 UTC (rev 1383) @@ -2,6 +2,7 @@ #include "fm1.h" #include "fm2.h" #include "fm3.h" +#include "fm4.h" #include <commons/rand.h> #include <commons/time.h> #include <boost/foreach.hpp> @@ -113,6 +114,14 @@ load(m, "fmap3 reload"); index(m, "fmap3 index"); } + { + fast_map4 m; + m.set_empty_key(-1); + m.set_deleted_key(-2); + load(m, "fmap4 init"); + load(m, "fmap4 reload"); + index(m, "fmap4 index"); + } cout << endl; } return 0; Modified: sandbox/trunk/src/cc/htons_conversion.cc =================================================================== --- sandbox/trunk/src/cc/htons_conversion.cc 2009-05-07 05:42:39 UTC (rev 1382) +++ sandbox/trunk/src/cc/htons_conversion.cc 2009-05-07 06:07:23 UTC (rev 1383) @@ -7,7 +7,8 @@ #include <arpa/inet.h> int main() { sockaddr_in sa; - unsigned short x = (unsigned short) htons((unsigned short)3); + // uint16_t x = (uint16_t) htons((uint16_t) 3); + unsigned short x = (unsigned short) htons((unsigned short) 3); sa.sin_port = x; return 0; } Added: sandbox/trunk/src/cc/inline2.cc =================================================================== --- sandbox/trunk/src/cc/inline2.cc (rev 0) +++ sandbox/trunk/src/cc/inline2.cc 2009-05-07 06:07:23 UTC (rev 1383) @@ -0,0 +1,21 @@ +// Demo that you can use inline with ctors and pure virtual methods. But they +// probably won't mean anything if the program triggers dynamic dispatch (i.e. +// only inlined where static information is complete). +#include <iostream> +using namespace std; +struct c { + inline virtual void f() = 0; +}; +struct d : public c { + inline d(int x) : x_(x) { + cout << "ctor" << endl; + } + inline virtual void f() { + cout << "f()" << endl; + } + int x_; +}; +int main() { + d(0).f(); + return 0; +} Added: sandbox/trunk/src/cc/iomanip.cc =================================================================== --- sandbox/trunk/src/cc/iomanip.cc (rev 0) +++ sandbox/trunk/src/cc/iomanip.cc 2009-05-07 06:07:23 UTC (rev 1383) @@ -0,0 +1,10 @@ +#include <iomanip> +#include <iostream> +using namespace std; + +int main() { + for (int i = 0; i < 20; ++i) + cout << hex << setfill('0') << setw(2) << i << ' '; + cout << endl; + return 0; +} Added: sandbox/trunk/src/cc/map.cc =================================================================== --- sandbox/trunk/src/cc/map.cc (rev 0) +++ sandbox/trunk/src/cc/map.cc 2009-05-07 06:07:23 UTC (rev 1383) @@ -0,0 +1,14 @@ +// Demo of map::lower_bound. +#include <map> +#include <iostream> +using namespace std; +int main() { + map<int, int> m; + for (int i = 0; i < 10; i++) { + m[i*100] = i; + } + for (int i = 90; i < 110; i++) { + cout << i << ": " << m.lower_bound(i)->first << endl; + } + return 0; +} Added: sandbox/trunk/src/cc/moves.cc =================================================================== --- sandbox/trunk/src/cc/moves.cc (rev 0) +++ sandbox/trunk/src/cc/moves.cc 2009-05-07 06:07:23 UTC (rev 1383) @@ -0,0 +1,44 @@ +#include <cstring> + +/** +* Move-able, conditionally-scoped array. +*/ +template<typename T> +class array_view { + public: + array_view(T *p, bool scoped) : p_(p), scoped_(scoped) {} + + // This is not allowed, of course, since there's an implicit copy just in + // passing in the argument. + // + // array_view(array_view<T> a) : p_(a.p_), scoped_(a.scoped_) { a.scoped_ = false; } + + // This won't get called for rvalue references. + array_view(array_view<T> &a) : p_(a.p_), scoped_(a.scoped_) { a.scoped_ = false; } + + // This requires C++0x. Yay for rvalue references! + array_view(array_view<T> &&a) : p_(a.p_), scoped_(a.scoped_) { a.scoped_ = false; } + + ~array_view() { if (scoped_) delete [] p_; } + T *get() { return p_; } + const T *get() const { return p_; } + operator T*() { return p_; } + operator const T*() const { return p_; } + bool scoped() const { return scoped_; } + private: + T *p_; + bool scoped_; +}; + +array_view<char> f() { return array_view<char>(new char[4], true); } + +int main() { + array_view<char> a(new char[4], true); + array_view<char> b(a); + array_view<char> c(b); + array_view<char> d(c); + d.get(); + array_view<char> e(f()); + e.get(); + return 0; +} Added: sandbox/trunk/src/cc/nonvirt_dtor.cc =================================================================== --- sandbox/trunk/src/cc/nonvirt_dtor.cc (rev 0) +++ sandbox/trunk/src/cc/nonvirt_dtor.cc 2009-05-07 06:07:23 UTC (rev 1383) @@ -0,0 +1,33 @@ +// (C) Copyright Beman Dawes 1999. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version including documentation. + +// Revision History +// 9 Jun 99 Add unnamed namespace +// 2 Jun 99 Initial Version + +#include <boost/noncopyable.hpp> +#include <iostream> + +// This program demonstrates compiler errors resulting from trying to copy +// construct or copy assign a class object derived from class noncopyable. + +namespace +{ + class DontTreadOnMe : private boost::noncopyable + { + public: + DontTreadOnMe() { std::cout << "defanged!" << std::endl; } + }; // DontTreadOnMe + +} // unnamed namespace + +int main() +{ + DontTreadOnMe object1; + DontTreadOnMe object2(object1); + object1 = object2; + return 0; +} // main Added: sandbox/trunk/src/cc/randperf.cc =================================================================== --- sandbox/trunk/src/cc/randperf.cc (rev 0) +++ sandbox/trunk/src/cc/randperf.cc 2009-05-07 06:07:23 UTC (rev 1383) @@ -0,0 +1,15 @@ +#include <iostream> +#include <commons/time.h> +#include <commons/rand.h> +using namespace std; +using namespace commons; +int main() { + int r = 0; + long long start = current_time_millis(); + for (int i = 0; i < 1000000; ++i) { + r |= randint(); + } + long long end = current_time_millis(); + cout << end - start << ' ' << r << endl; + return 0; +} Modified: sandbox/trunk/src/cc/rvaluerefs.cc =================================================================== --- sandbox/trunk/src/cc/rvaluerefs.cc 2009-05-07 05:42:39 UTC (rev 1382) +++ sandbox/trunk/src/cc/rvaluerefs.cc 2009-05-07 06:07:23 UTC (rev 1383) @@ -1,16 +1,23 @@ // Demo that in gcc 4.3 rvalue references are not quite up to spec. In // particular, move() doesn't seem to be required anywhere. +#include <utility> // for move() +#include <boost/unique_ptr.hpp> +using namespace std; + struct A {}; void bar(A &&) {} void foo(A &&a) { bar(a); } struct B { - B() : p(0) {} - B(B &&b) : p(b.p) {} + B(A *p = 0) : p(p) {} + ~B() { delete p; } + B(B &&b) : p(b.p) { b.p = 0; } + B &operator=(B &&b) { p = b.p; b.p = 0; return *this; } private: - void *p; + A *p; B(const B&); + B &operator=(const B&); }; int main() { @@ -21,9 +28,13 @@ foo(b); } { - B a; - B b; - b = a; + B a(new A()); + B b(move(a)); + B c; + c = move(a); } + { + foo(A()); + } return 0; } Modified: sandbox/trunk/src/cc/smartptrs.cc =================================================================== --- sandbox/trunk/src/cc/smartptrs.cc 2009-05-07 05:42:39 UTC (rev 1382) +++ sandbox/trunk/src/cc/smartptrs.cc 2009-05-07 06:07:23 UTC (rev 1383) @@ -3,16 +3,21 @@ // NOT what we want: // #include <boost/interprocess/smart_ptr/unique_ptr.hpp> #include <memory> -#include <commons/boost/unique_ptr.hpp> +#include <commons/unique_ptr.hpp> using namespace boost; // using namespace boost::interprocess; using namespace std; +void foo(scoped_array<int> &b) { + scoped_array<int> a(new int[5]); + swap(a,b); +} int main() { scoped_array<int> a(new int[5]); scoped_array<int> b; swap(a,b); - unique_ptr<int[]> u(new int[5]); + unique_ptr<int> u(new int(0)); + // unique_ptr<int[]> u(new int[5]); auto_ptr<int> p(new int(3)); Added: sandbox/trunk/src/cc/streambufs.cc.cog =================================================================== --- sandbox/trunk/src/cc/streambufs.cc.cog (rev 0) +++ sandbox/trunk/src/cc/streambufs.cc.cog 2009-05-07 06:07:23 UTC (rev 1383) @@ -0,0 +1,62 @@ +#include <iostream> +#include <sstream> +using namespace std; + +#define trace(line) \ + cout << "\n" #line "\n"; \ + line + +class mystreambuf : public stringbuf { + public: + mystreambuf() {} + + template<typename T> + mystreambuf(T x) : stringbuf(x) {} + + void explore() { + cout + // [[[cog + // import cog + // for i in range(2): + // cog.outl(r'<< "\n putsize " << epptr() - pbase()') + // cog.outl(r'<< "\n getsize " << egptr() - eback()') + // for fn in 'eback gptr egptr pbase pptr epptr'.split(): + // cog.outl(r'<< "\n %s " << (void*) %s()' % (fn,fn)) + // for fn in 'in_avail showmanyc'.split(): + // cog.outl(r'<< "\n %s " << %s()' % (fn,fn)) + // if i == 0: cog.outl(r'<< "\n --"') + // ]]] + // [[[end]]] + << endl; + } +}; + +int main() { + char buf[5] = "abc"; + if (0) { + trace(mystreambuf sb); + sb.explore(); + trace(sb.sputn(buf, sizeof buf)); + sb.explore(); + trace(sb.sgetn(buf, sizeof buf)); + sb.explore(); + } + if (0) { + trace(mystreambuf sb("abc")); + sb.explore(); + } + if (1) { + trace(mystreambuf sb); + sb.explore(); + trace(sb.pubsetbuf(buf, sizeof buf)); + sb.explore(); + for (size_t i = 0; i < sizeof buf; ++i) + cout << sb.sbumpc() << endl; + sb.pubseekpos(0); + for (size_t i = 0; i <= sizeof buf; ++i) + cout << sb.sbumpc() << endl; + } + return 0; +} + +// vim:ft=cpp Added: sandbox/trunk/src/cc/unordered_map.cc =================================================================== --- sandbox/trunk/src/cc/unordered_map.cc (rev 0) +++ sandbox/trunk/src/cc/unordered_map.cc 2009-05-07 06:07:23 UTC (rev 1383) @@ -0,0 +1,26 @@ +// Added demo of using various map types. +// See also container-bench on assorted.sf.net + +#include <tr1/unordered_map> +#include <google/dense_hash_map> +#include <iostream> + +using namespace std; +using namespace tr1; +using namespace google; + +int main() { + dense_hash_map<int, int> m; + m.set_empty_key(-1); + for (int i = 0; i < 100; ++i) + m[i] = 2*i; + cout << "bucket_count = " << m.bucket_count() << endl; + + for (size_t b = 0; b < m.bucket_count(); ++b) { + // cout << "bucket_size(" << b << ") = " << m.bucket_size(b) << endl; + m.begin(b); + } + + cout << "done" << endl; + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 05:42:40
|
Revision: 1382 http://assorted.svn.sourceforge.net/assorted/?rev=1382&view=rev Author: yangzhang Date: 2009-05-07 05:42:39 +0000 (Thu, 07 May 2009) Log Message: ----------- added setitimer demo Added Paths: ----------- sandbox/trunk/src/c/setitimer.c Added: sandbox/trunk/src/c/setitimer.c =================================================================== --- sandbox/trunk/src/c/setitimer.c (rev 0) +++ sandbox/trunk/src/c/setitimer.c 2009-05-07 05:42:39 UTC (rev 1382) @@ -0,0 +1,71 @@ +// Demo of how setitimer doesn't send signals when the program is blocked +// sleeping on an IO call. + +#include <errno.h> +#include <signal.h> +#include <stdio.h> +#include <unistd.h> +#include <sys/time.h> +#include <time.h> +#include <pthread.h> + +volatile int counter; + +static void myhandler(int s) { + char aster = '*'; + int errsave; + errsave = errno; + write(STDERR_FILENO, &aster, 1); + errno = errsave; + counter += 1; +} + +static int setupinterrupt(void) { /* set up myhandler for SIGPROF */ + struct sigaction act; + act.sa_handler = myhandler; + act.sa_flags = 0; + return (sigemptyset(&act.sa_mask) || sigaction(SIGPROF, &act, NULL)); +} + +static int setupitimer(void) { /* set ITIMER_PROF for 2-second intervals */ + struct itimerval value; + value.it_interval.tv_sec = 0; + value.it_interval.tv_usec = 100000; + value.it_value = value.it_interval; + return (setitimer(ITIMER_PROF, &value, NULL)); +} + +void *f(void *p) { + usleep(1000000); + return 0; +} + +int main(void) { + if (setupinterrupt()) { + perror("Failed to set up handler for SIGPROF"); + return 1; + } + if (setupitimer() == -1) { + perror("Failed to set up the ITIMER_PROF interval timer"); + return 1; + } + + while (counter < 3); + + printf("\nsleeping..."); + fflush(stdout); + usleep(350000); + printf("done.\n"); + + printf("sleeping..."); + fflush(stdout); + pthread_t t; + pthread_create(&t, 0, &f, 0); + pthread_join(t, 0); + printf("done.\n"); + + while (counter < 6); + printf("\n"); + + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 05:41:49
|
Revision: 1381 http://assorted.svn.sourceforge.net/assorted/?rev=1381&view=rev Author: yangzhang Date: 2009-05-07 05:41:48 +0000 (Thu, 07 May 2009) Log Message: ----------- tweaks; added custom "xstream" abstraction Modified Paths: -------------- serialization-bench/trunk/src/main.cc Modified: serialization-bench/trunk/src/main.cc =================================================================== --- serialization-bench/trunk/src/main.cc 2009-05-07 05:39:31 UTC (rev 1380) +++ serialization-bench/trunk/src/main.cc 2009-05-07 05:41:48 UTC (rev 1381) @@ -15,15 +15,17 @@ using namespace commons; using namespace std; -int cnt = 1e6, reps = 3; +int cnt = 5e6, reps = 3; struct exp { void time() { + long long start = current_time_millis(); build(); - long long start = current_time_millis(); + long long mid = current_time_millis(); run(); long long end = current_time_millis(); - cout << name << ": " << end - start << " ms, " << size() << " b" << endl; + cout << name << ": " << end - mid << " ms, build " << mid - start + << " ms, " << size() << " b" << endl; } virtual void build() {} virtual void run() = 0; @@ -104,6 +106,7 @@ struct protobuf_array : virtual protobuf { char *s; protobuf_array() : s(new char[2 * cnt * sizeof(int)]) {} + ~protobuf_array() { delete [] s; } void run() { a.SerializeToArray(s, 2 * cnt * sizeof(int)); } }; @@ -126,6 +129,7 @@ struct raw_array : virtual exp { char *a; raw_array() : a(new char[cnt * sizeof(int)]) {} + ~raw_array() { delete [] a; } void run() { int *p = (int*) a; for (int i = 0; i < cnt; ++i) { @@ -134,6 +138,34 @@ } }; +//template<typename T> +//class chunk { +//public: +// chunk() : +//}; + +class xstream { +public: + xstream() : a(new char[2 * cnt * sizeof(int)]), p(a) {} + ~xstream() { delete [] a; } + inline void put(int i) { + *((int*)p) = i; + p += sizeof(int); + } +private: + char *a; + char *p; +}; + +struct xstream_exp : virtual exp { + xstream s; + void run() { + for (int i = 0; i < cnt; ++i) { + s.put(i); + } + } +}; + #define rep(x) \ for (int r = 0; r < reps; ++r) \ x().named(#x).time(); @@ -149,6 +181,7 @@ rep(protobuf_array); rep(protobufs_string); rep(raw_array); + rep(xstream_exp); #if 0 cout << "SIZES" << endl; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 05:39:36
|
Revision: 1380 http://assorted.svn.sourceforge.net/assorted/?rev=1380&view=rev Author: yangzhang Date: 2009-05-07 05:39:31 +0000 (Thu, 07 May 2009) Log Message: ----------- made ssh key optional Modified Paths: -------------- sharing-gateway/trunk/src/gateway.py Modified: sharing-gateway/trunk/src/gateway.py =================================================================== --- sharing-gateway/trunk/src/gateway.py 2009-05-07 05:37:56 UTC (rev 1379) +++ sharing-gateway/trunk/src/gateway.py 2009-05-07 05:39:31 UTC (rev 1380) @@ -54,8 +54,10 @@ sudo( 'mount -t cifs -o'.split() + [ 'user=%(user)s,pass=%(pass)s,ip=%(ip)s' % d, s.share, mountpt ] ) elif s.type == 'sshfs': - sudo( [ 'sshfs', s.share, mountpt, - '-o', 'IdentityFile=%(key)s' % d, '-o', 'allow_other' ] ) + flags = [] + if 'key' in d: flags += [ '-o', 'IdentityFile=%(key)s' % d ] + sudo( [ 'sshfs', s.share, mountpt, '-o', 'allow_other' ] + + flags ) elif s.type == 'bind': sudo( [ 'mount', '--bind', s.share, mountpt ] ) else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 05:38:02
|
Revision: 1379 http://assorted.svn.sourceforge.net/assorted/?rev=1379&view=rev Author: yangzhang Date: 2009-05-07 05:37:56 +0000 (Thu, 07 May 2009) Log Message: ----------- - made pickle_memoized use binary mode pickling Modified Paths: -------------- python-commons/trunk/src/commons/decs.py Modified: python-commons/trunk/src/commons/decs.py =================================================================== --- python-commons/trunk/src/commons/decs.py 2009-05-07 05:36:34 UTC (rev 1378) +++ python-commons/trunk/src/commons/decs.py 2009-05-07 05:37:56 UTC (rev 1379) @@ -153,4 +153,6 @@ """ Wrapper around L{file_memoized} that uses pickle. """ - return file_memoized(dump, load, pathfunc) + bindump = lambda x,f: dump(x,f,2) + binload = lambda x,f: load(x,f,2) + return file_memoized(bindump, binload, pathfunc) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-05-07 05:36:38
|
Revision: 1378 http://assorted.svn.sourceforge.net/assorted/?rev=1378&view=rev Author: yangzhang Date: 2009-05-07 05:36:34 +0000 (Thu, 07 May 2009) Log Message: ----------- added flac2mp3 Modified Paths: -------------- shell-tools/trunk/src/bash-commons/common.bash Modified: shell-tools/trunk/src/bash-commons/common.bash =================================================================== --- shell-tools/trunk/src/bash-commons/common.bash 2009-05-07 05:36:15 UTC (rev 1377) +++ shell-tools/trunk/src/bash-commons/common.bash 2009-05-07 05:36:34 UTC (rev 1378) @@ -526,6 +526,12 @@ sed -i 's/Standards-Version: .*/Standards-Version: 3.8.0/' debian/control } +flac2mp3() { + for i in "$@" + do flac -cd "$i" | lame - "${i%flac}mp3" + done +} + #if ! is_declared indent ; then # noindent #else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |