Hi Rasmus, At Fri, 22 Jul 2011 11:12:46 +0200, Rasmus wrote: > : > > * Display multiple-lines items (the source splits an item multiple lines.) > > > > This is not so difficult. In this mechanism, the source objects can > > propose some formats, for example, "15:00 appointment" and ("15:00-15:30" > > "appointment"). Then, calfw chooses the suitable format and displays > > in the current layout algorithm. > > It could be a string similar to how BBDB, Gnus and other Emacs mode does > it. See for example (describe-variable 'gnus-summary-line-format). > > User could specify calfw:timeview-format "%Starttime-%Endtime: %Event" > or whatever.
Thanks for references. I will check them. > > * Word-wrapping and folding lines (calfw splits lines within a column.) > > > > This is little difficult. I think word-wrapping, folding lines and > > truncating strings can not be achieved in the narrow columns > > straightforwardly. I need a time to study this issue. > > Hmm, > I guess the width of column is calculated when generating the view. > I'll use pseudo-code as my Emacs Lisp isn't great. > #+begin_src emacs-lisp > (if (> (calfw:timeview-entry-length) (calfw:column-length)) > (#split-entry after column-length, preferbly after word > # and retur > ) > #+end_src > I hope it makes sense. . . Yes. The code is the start point. I would discuss how to split a line. I show two simple code as following: (Note: These codes include Japanese characters.) * Simple counting and splitting This code splits words mechanically. I think it is bad for the Western languages. However, for the Eastern Asian languages, this result is not bad. #+begin_src emacs-lisp (let ((str "The quick brown fox jumped over the lazy dog. The internationalization and Localization are long words. 日本語を含むときの場合。") (fill-column 10)) (loop with ret = nil with curcol = 0 with lastpos = 0 with endpos = (1- (length str)) for i from 0 upto endpos for c = (aref str i) for w = (char-width c) if (or (= endpos i) (<= fill-column (+ curcol w))) do (push (substring str lastpos (1+ i)) ret) (setq lastpos (1+ i) curcol 0) else do (incf curcol w) finally return (mapconcat 'identity (nreverse ret) "\n"))) ; => "The quick brown fox jumped ove r the lazy dog. The internatio nalization and Local ization ar e long wor ds. 日本語 を含むとき の場合。" #+end_src * Word-wrapping by fill function of Emacs This splitting is smarter, but not perfect. Long words are still need truncation or hyphenation. #+begin_src emacs-lisp (let ((str "The quick brown fox jumped over the lazy dog. The internationalization and Localization are long words. 日本語を含むときの場合。") (fill-column 10)) (with-temp-buffer (insert str) (fill-region (point-min) (point-max)) (buffer-string))) ; => "The quick brown fox jumped over the lazy dog. The internationalization and Localization are long words. 日本 語を含むと きの場合。" #+end_src So, I think I should study the word-wrapping algorithm. If someone knows better algorithm or implementations, please let me know. Regards, -- SAKURAI, Masashi (family, given) m.saku...@kiwanami.net