195 Commits

Author SHA1 Message Date
slotThe
404b3f59b4 X.Prompt: correctly update history
So far, when `alwaysHighlight' was enabled and the user selected an item
while not having completely written it out in the prompt, the input
string and not the eventual completion string would be entered into the
prompt history, which is obviously not the desired behaviour.  This can
cause the history to clutter up with all these abbreviations, making
subsequent invocations of the prompt tedious to work with.

For example, an input of "xm" would narrow to both "xmonad" and
"xmobar", but thanks to `alwaysHighlight' "xmobar" was selected.  If the
user now pressed enter, the prompt would correctly return "xmobar" as
the string to act upon, but "xm" would be entered into the prompt
history!
2021-01-08 17:08:53 +01:00
slotThe
9d520dc880 X.Prompt: X constraint for historyCompletion[P]
This is needed because the cache directory is now a part of XConf, which
is calculated once on startup and hence any recalculation would be
fragile.

Some internal functions that are not exposed (like writeHistory) were
also changed to accept that directory as an argument.
2021-01-07 10:33:47 +01:00
slotThe
526336ecec Only modify the last word during tab completion
Fixes #164.

It's not clear to me why these functions take in XPState as a param only
to then produce some XP () values. It seems like they could just as well
call `get`.
2021-01-04 10:17:28 +01:00
slotThe
5140f5b5d0 Remove things deprecated by Data.Default 2020-11-16 10:31:02 +01:00
ivanbrennan
b63159fd00
add complCaseSensitivity field to XPConfig 2020-09-28 21:51:45 -04:00
ivanbrennan
795be75a58
prompt completion: case-sensitivity
Provide a way to perform case-insensitive file / directory completion.
We're using compgen to generate completion candidates, and this is
case-sensitive by default. We can control this by setting the
completion-ignore-case Readline variable prior to invoking compgen. If
we're running a Bash with Readline support, this works as expected.
Otherwise, it has no effect -- completion candidates are still returned,
but compgen generates them in a case-sensitive manner.

To avoid breaking changes, the signatures and behavior of existing
exported functions are unchanged:
  - XMonad.Layout.WorkspaceDir.changeDir
  - XMonad.Prompt.Directory.directoryPrompt
  - XMonad.Prompt.Shell.getShellCompl

New variations of these functions are provided, allowing the caller
to specify the desired case-sensitivity via a ComplCaseSensitivity
argument:
  - XMonad.Layout.WorkspaceDir.changeDir'
  - XMonad.Prompt.Directory.directoryPrompt'
  - XMonad.Prompt.Shell.getShellCompl'

The XMonad.Prompt.Shell exports a couple new functions:
  - compgenDirectories
  - compgenFiles

We make use of this in XMonad.Prompt.Directory to avoid duplicating the
compgen code.
2020-09-24 07:57:33 -04:00
Daniel Gorin
28b3e34fd7 Prompt: Use searchPredicate in more cases
Prompts based on `mkComplFunList` and `mkComplFunList'` were not
taking into account the `searchPredicate` funtion from `XPConfig`.
This was rather confusing.

We fix it by passing `XPConfig` to these functions; although
this is strictly more than they need, it makes the breaking change very
easy to fix and is also more future-proof.
2019-11-18 20:13:40 +00:00
slotThe
bcd4dde298 Remove redundant do's 2019-10-11 16:35:54 +02:00
slotThe
273ae32438 Replace 'join . fmap' with =<< 2019-10-08 11:19:09 +02:00
slotThe
e8da66e575 Replace liftM with fmap 2019-10-08 10:45:44 +02:00
slotThe
f3024e6779 Remove unnecessary imports of Control.Applicative 2019-10-08 10:21:15 +02:00
Brent Yorgey
60b35ff431
Merge branch 'master' into bracket-prompt-resources 2019-02-12 09:13:51 -06:00
Michael Sloan
d9f43c78d6 Fix XMonad.Prompt wraparound when maxComplRows not Nothing #217 2019-02-10 04:47:16 -08:00
Michael Sloan
b9603a0e10 Also destroy completion window on exceptions #180 2019-02-10 04:18:56 -08:00
Michael Sloan
09a5fa111c Use bracket pattern in XMonad.Prompt 2019-02-10 04:18:30 -08:00
Michael Sloan
41a2db5563 Refactoring: helper for mkXPromptWithReturn and mkXPromptWithModes 2019-02-10 03:51:40 -08:00
Yclept Nemo
207d5962e2 Vim for 'XMonad.Prompt': backwards compatibility
Colors in 'XPState' continue to use 'XPColor' since it provides a
cleaner interface. For backwards compatibility color changes to
'XPConfig' were reverted. To avoid accessor clashes you'll have to deal
with slightly different names:

| 'XPState'/'XPColor' | 'XPConfig'  |
| ------------------- | ----------- |
| bgNormal            | bgColor     |
| fgNormal            | fgColor     |
| bgHighlight         | bgHLight    |
| fgHighlight         | fgHLight    |
| border              | borderColor |
2019-01-26 15:18:27 -05:00
Yclept Nemo
b0d6e0f942 Vim for 'XMonad.Prompt':
A vim-like keymap, yay! And dynamic colors and a reworked event loop.
Also fixes 'showCompletionOnTab' which was broken, and many new or
improved prompt interface functions.

Changes moveWord/moveWord' but updates the old keymaps to retain the
original behavior. See the documentation to do the same to your XMonad
configuration.

P.S. That bug I mention was there before my changes.
2019-01-26 14:49:52 -05:00
Leary
204524328d
Merge pull request #282 from anthraxx/fixup/prompt-fuzzymatch
XMonad.Prompt sorter for FuzzyMatch
2018-10-18 05:36:51 +13:00
Peter Simons
5334130bf7 historyCompletion: prefer Data.Map.foldr over deprecated fold function 2018-09-28 11:44:49 +02:00
Sergey Alirzaev
6b9fb096d6 employ the prompt sorter for the window selector
as in https://markmail.org/thread/kgrybzqarqzqiige
2018-09-25 22:15:45 +02:00
foreverbell
96e9cab753
Export XMonad.Prompt.insertString. 2017-07-23 00:52:43 +08:00
Peter J. Jones
9d2ffeb8e1 Merge pull request #139 from mekeor/better-xpc-font-description
Better description of 'font' field of 'XPC' record
2017-02-13 12:15:59 -07:00
Mekeor Melire
878987071b Better description of 'font' field of 'XPC' record
Describe how to use the 'font' field of 'XPC' record by adding two different examples.
2017-02-13 13:25:25 +01:00
Peter Jones
57c00b1086
Better completion when using `alwaysHighlight'
This change improves the UX of X.Prompt when `alwaysHighlight` is
enabled.  This is especially useful for use with `mkXPromptWithModes`
which forces `alwaysHighlight` to be `True`.

When the user presses the `complKey` and `alwaysHighlight` is `True`,
one of two things will happen:

  1. If this is the first time `complKey` is pressed in this round of
     completion then the prompt buffer will be updated so it contains
     the currently highlighted item.

  2. Every other time that the `complKey` is pressed the next
     completion item will be selected and the prompt buffer updated.

This gives immediate feedback to the user and allows using some
prompts with `alwaysHighlight` that weren't possible before (e.g.,
shellPrompt, directoryPrompt, etc.)
2017-02-05 19:38:00 -07:00
Peter Jones
74b281b5d3
Use the new getXMonadCacheDir function from #62
Prompt should have been using getXMonadDir this entire time but since
we now have getXMonadCacheDir use that instead.  This brings
xmonad-contrib inline with the changes in #62.

This also fixes xmonad/xmonad-contrib#68
2017-01-04 14:39:00 -07:00
Sam Doshi
dcc2759c4d fix broken XPConfig docs 2016-10-19 11:41:06 +01:00
Daniel Wagner
d6243c9564 improve documentation on fonts in Prompt 2016-06-22 13:17:28 -07:00
Bogdan Sinitsyn
30f657a437 strip numlock from mask in X.Prompt(fixes #37) 2016-02-14 14:54:26 +03:00
Bogdan Sinitsyn
4a9e28ca8b Merge branch 'master' of https://github.com/xmonad/xmonad-contrib into prompt-position 2016-01-10 23:43:11 +03:00
Sibi Prabakaran
727e214195 Add multiple key support for completion key
This patch enables support for key binding like Ctrl + i which was not
previously possible. Technically, this changes the type of completionKey
from KeySym to (KeyMask, KeySym).
2016-01-10 23:17:00 +05:30
Bogdan Sinitsyn
9a7a63bfb4 improve documentation for X.Prompt 2016-01-08 20:58:56 +03:00
Bogdan Sinitsyn
a61ce8dd74 improve documentation for X.Prompt 2016-01-08 20:29:45 +03:00
Bogdan Sinitsyn
bce9c551ef fix CenteredAt in X.Prompt 2016-01-01 00:22:45 +03:00
Bogdan Sinitsyn
26309d1622 improve CenteredAt in X.Prompt 2015-12-31 23:51:03 +03:00
Bogdan Sinitsyn
d81b4e5bcb add documentation for XPPosition in X.Prompt 2015-12-31 23:36:07 +03:00
Bogdan Sinitsyn
6043914841 fix border between prompt and completions in X.Prompt 2015-12-31 16:03:00 +03:00
Bogdan Sinitsyn
ed7be9a791 fix border between prompt and completion window in X.Prompt 2015-12-31 15:57:36 +03:00
Bogdan Sinitsyn
becb724f95 fix prompt width 2015-12-28 19:37:52 +03:00
Bogdan Sinitsyn
0447c76d48 change documentation 2015-12-28 15:19:02 +03:00
Bogdan Sinitsyn
e47794148c fix border drawing 2015-12-28 15:14:35 +03:00
Bogdan Sinitsyn
edd6b8be55 add customization for prompt position 2015-12-28 14:49:36 +03:00
Kurnevsky Evgeny
09f3c3fbea Bugfix for moveHistory when alwaysHighlight is enabled. 2015-12-09 17:50:15 +03:00
Adam Vogt
6cbddae8c2 add another extension to actually fix the build with ghc-7.10-RC1 2015-01-24 11:19:39 +00:00
Daniel Wagner
0f1b6fb772 use Data.Default wherever possible, and deprecate the things it replaces 2013-05-28 01:39:09 +00:00
Paul Fertser
8bfe148416 Allow to limit maximum row count in X.Prompt completion window
On a keyboard-less device (such as a smartphone), where one has to use
an on-screen keyboard, the maximum completion window height must be
limited to avoid overlapping the keyboard.
2013-02-21 12:20:50 +00:00
c.lopez
34800741e5 spawn command when no completion is available (if alwaysHighlight is True); changes commandToComplete in Prompt/Shell to complete the whole word instead of using getLastWord 2013-02-09 19:04:56 +00:00
Adam Vogt
895c47fb4e Record polachok's fix for issue 507 2012-12-16 18:27:24 +00:00
Adam Vogt
3fa51ed656 Use Control.Exception.catch explitly to avoid warnings
The base that comes with ghc-7.6.1 no longer includes Prelude.catch;
so these modules were changed so that there is no warning for

import Prelude hiding (catch)

At the same time these changes should be compatible with older GHCs,
since the catch being has never been the one in the Prelude.
2012-11-09 01:35:06 +00:00
c.lopez
0af63a4767 Improves haddock documentation 2012-08-26 09:17:16 +00:00